From 83b62a4953e11f1efe1c1881a5fdad87f833cb4d Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sat, 20 Aug 2022 22:44:03 +0200 Subject: [PATCH] with formatting --- package.json | 3 +- scripts/generate_graphql.sh | 1 + src/lib/graphql/generated.ts | 110 ++++++++++++++++++++++------------- 3 files changed, 74 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index b70c67b..2ef9416 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "dev": "next dev", "build": "next build", "start": "next start", - "generate:graphql": "graphql-codegen" + "generate:graphql": "graphql-codegen", + "format:graphql": "prettier -w src/lib/graphql/generated.ts" }, "dependencies": { "@apollo/client": "^3.6.9", diff --git a/scripts/generate_graphql.sh b/scripts/generate_graphql.sh index 0ae157f..524eb13 100755 --- a/scripts/generate_graphql.sh +++ b/scripts/generate_graphql.sh @@ -5,5 +5,6 @@ set -e cuddle_cli x download pnpm run generate:graphql +pnpm run format:graphql git diff src/lib/graphql/generated.ts diff --git a/src/lib/graphql/generated.ts b/src/lib/graphql/generated.ts index 516c156..39daa20 100644 --- a/src/lib/graphql/generated.ts +++ b/src/lib/graphql/generated.ts @@ -1,10 +1,16 @@ -import { gql } from '@apollo/client'; -import * as Apollo from '@apollo/client'; +import { gql } from "@apollo/client"; +import * as Apollo from "@apollo/client"; export type Maybe = T | null; export type InputMaybe = Maybe; -export type Exact = { [K in keyof T]: T[K] }; -export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; -export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; +export type Exact = { + [K in keyof T]: T[K]; +}; +export type MakeOptional = Omit & { + [SubKey in K]?: Maybe; +}; +export type MakeMaybe = Omit & { + [SubKey in K]: Maybe; +}; const defaultOptions = {} as const; /** All built-in and custom scalars, mapped to their actual values */ export type Scalars = { @@ -16,45 +22,50 @@ export type Scalars = { }; export type Event = { - __typename?: 'Event'; + __typename?: "Event"; date: EventDate; - description?: Maybe>; - id: Scalars['String']; - location?: Maybe; - name: Scalars['String']; + description?: Maybe>; + id: Scalars["String"]; + location?: Maybe; + name: Scalars["String"]; }; export type EventDate = { - __typename?: 'EventDate'; - day: Scalars['Int']; - hour: Scalars['Int']; - minute: Scalars['Int']; - month: Scalars['Int']; - year: Scalars['Int']; + __typename?: "EventDate"; + day: Scalars["Int"]; + hour: Scalars["Int"]; + minute: Scalars["Int"]; + month: Scalars["Int"]; + year: Scalars["Int"]; }; export type QueryRoot = { - __typename?: 'QueryRoot'; + __typename?: "QueryRoot"; getUpcoming: Array; }; -export type GetUpcomingQueryVariables = Exact<{ [key: string]: never; }>; - - -export type GetUpcomingQuery = { __typename?: 'QueryRoot', getUpcoming: Array<{ __typename?: 'Event', name: string, date: { __typename?: 'EventDate', day: number, hour: number } }> }; +export type GetUpcomingQueryVariables = Exact<{ [key: string]: never }>; +export type GetUpcomingQuery = { + __typename?: "QueryRoot"; + getUpcoming: Array<{ + __typename?: "Event"; + name: string; + date: { __typename?: "EventDate"; day: number; hour: number }; + }>; +}; export const GetUpcomingDocument = gql` - query GetUpcoming { - getUpcoming { - name - date { - day - hour + query GetUpcoming { + getUpcoming { + name + date { + day + hour + } } } -} - `; +`; /** * __useGetUpcomingQuery__ @@ -71,14 +82,35 @@ export const GetUpcomingDocument = gql` * }, * }); */ -export function useGetUpcomingQuery(baseOptions?: Apollo.QueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useQuery(GetUpcomingDocument, options); - } -export function useGetUpcomingLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { - const options = {...defaultOptions, ...baseOptions} - return Apollo.useLazyQuery(GetUpcomingDocument, options); - } +export function useGetUpcomingQuery( + baseOptions?: Apollo.QueryHookOptions< + GetUpcomingQuery, + GetUpcomingQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery( + GetUpcomingDocument, + options + ); +} +export function useGetUpcomingLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetUpcomingQuery, + GetUpcomingQueryVariables + > +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery( + GetUpcomingDocument, + options + ); +} export type GetUpcomingQueryHookResult = ReturnType; -export type GetUpcomingLazyQueryHookResult = ReturnType; -export type GetUpcomingQueryResult = Apollo.QueryResult; \ No newline at end of file +export type GetUpcomingLazyQueryHookResult = ReturnType< + typeof useGetUpcomingLazyQuery +>; +export type GetUpcomingQueryResult = Apollo.QueryResult< + GetUpcomingQuery, + GetUpcomingQueryVariables +>;