-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example of
TypedDocumentNode
codegen
this is the reference that I followed: https://github.com/dotansimha/graphql-typed-document-node#how-to-use
- Loading branch information
Showing
7 changed files
with
1,961 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
schema: test/graphql-api/typed-document-node.schema.graphql | ||
documents: test/graphql-api/typed-document-node.*.graphql | ||
generates: | ||
test/graphql-api/typed-document-node.graphql-operations.ts: | ||
plugins: | ||
- typescript | ||
- typescript-operations | ||
- typed-document-node |
65 changes: 65 additions & 0 deletions
65
test/graphql-api/typed-document-node.graphql-operations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; | ||
export type Maybe<T> = T | null; | ||
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] }; | ||
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> }; | ||
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> }; | ||
/** All built-in and custom scalars, mapped to their actual values */ | ||
export type Scalars = { | ||
ID: string; | ||
String: string; | ||
Boolean: boolean; | ||
Int: number; | ||
Float: number; | ||
}; | ||
|
||
export type Mutation = { | ||
__typename?: 'Mutation'; | ||
login: User; | ||
}; | ||
|
||
|
||
export type MutationLoginArgs = { | ||
username: Scalars['String']; | ||
}; | ||
|
||
export type Query = { | ||
__typename?: 'Query'; | ||
user: User; | ||
}; | ||
|
||
export type User = { | ||
__typename?: 'User'; | ||
id: Scalars['ID']; | ||
firstName: Scalars['String']; | ||
age: Scalars['Int']; | ||
}; | ||
|
||
export type LoginMutationVariables = Exact<{ | ||
username: Scalars['String']; | ||
}>; | ||
|
||
|
||
export type LoginMutation = ( | ||
{ __typename?: 'Mutation' } | ||
& { login: ( | ||
{ __typename?: 'User' } | ||
& Pick<User, 'id'> | ||
) } | ||
); | ||
|
||
export type GetUserDetailQueryVariables = Exact<{ | ||
userId: Scalars['String']; | ||
}>; | ||
|
||
|
||
export type GetUserDetailQuery = ( | ||
{ __typename?: 'Query' } | ||
& { user: ( | ||
{ __typename?: 'User' } | ||
& Pick<User, 'id' | 'firstName' | 'age'> | ||
) } | ||
); | ||
|
||
|
||
export const LoginDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Login"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"username"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"login"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"username"},"value":{"kind":"Variable","name":{"kind":"Name","value":"username"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode<LoginMutation, LoginMutationVariables>; | ||
export const GetUserDetailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetUserDetail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"userId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"firstName"}},{"kind":"Field","name":{"kind":"Name","value":"age"}}]}}]}}]} as unknown as DocumentNode<GetUserDetailQuery, GetUserDetailQueryVariables>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mutation Login($username: String!) { | ||
login(username: $username) { | ||
id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query GetUserDetail($userId: String!) { | ||
user { | ||
id | ||
firstName | ||
age | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type User { | ||
id: ID! | ||
firstName: String! | ||
age: Int! | ||
} | ||
|
||
type Query { | ||
user: User! | ||
} | ||
|
||
type Mutation { | ||
login(username: String!): User! | ||
} |
Oops, something went wrong.