diff --git a/GraphQLTypeDefinitions.graphql b/GraphQLTypeDefinitions.graphql index 87aa5ff7..a31f66bd 100644 --- a/GraphQLTypeDefinitions.graphql +++ b/GraphQLTypeDefinitions.graphql @@ -4,7 +4,9 @@ Instruction for establishing a live connection that is updated once the underlying data changes. """ directive @live( - """Whether the query should be live or not.""" + """ + Whether the query should be live or not. + """ if: Boolean = true """ diff --git a/src/gql/fragment-masking.ts b/src/gql/fragment-masking.ts index 452def84..95e82089 100644 --- a/src/gql/fragment-masking.ts +++ b/src/gql/fragment-masking.ts @@ -1,21 +1,17 @@ -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core"; - -export type FragmentType> = TDocumentType extends DocumentNode< - infer TType, - any -> - ? TType extends { ' $fragmentName': infer TKey } - ? TKey extends string - ? { ' $fragmentRefs': { [key in TKey]: TType } } +export type FragmentType> = + TDocumentType extends DocumentNode + ? TType extends { " $fragmentName": infer TKey } + ? TKey extends string + ? { " $fragmentRefs": { [key in TKey]: TType } } + : never : never - : never - : never; - + : never; export function useFragment( _documentNode: DocumentNode, fragmentType: FragmentType> ): TType { - return fragmentType as any + return fragmentType as any; } diff --git a/src/gql/gql.ts b/src/gql/gql.ts index 42ec17cb..739ed2cf 100644 --- a/src/gql/gql.ts +++ b/src/gql/gql.ts @@ -1,26 +1,45 @@ /* eslint-disable */ -import * as graphql from './graphql'; -import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'; +import * as graphql from "./graphql"; +import { TypedDocumentNode as DocumentNode } from "@graphql-typed-document-node/core"; const documents = { - "\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n": graphql.CharacterQueryDocument, - "\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n": graphql.CharacterEditorQueryDocument, - "\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n": graphql.UpdateCharacterMutationDocument, - "\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n": graphql.CharacterViewFragmentFragmentDoc, - "\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n": graphql.CharacterOverlayFragmentFragmentDoc, - "\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n": graphql.CreateCharacterMutationDocument, + "\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n": + graphql.CharacterQueryDocument, + "\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n": + graphql.CharacterEditorQueryDocument, + "\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n": + graphql.UpdateCharacterMutationDocument, + "\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n": + graphql.CharacterViewFragmentFragmentDoc, + "\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n": + graphql.CharacterOverlayFragmentFragmentDoc, + "\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n": + graphql.CreateCharacterMutationDocument, }; -export function gql(source: "\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n"): (typeof documents)["\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n"]; -export function gql(source: "\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n"): (typeof documents)["\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n"]; -export function gql(source: "\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n"): (typeof documents)["\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n"]; -export function gql(source: "\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n"): (typeof documents)["\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n"]; -export function gql(source: "\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n"): (typeof documents)["\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n"]; -export function gql(source: "\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n"): (typeof documents)["\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n"]; +export function gql( + source: "\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n" +): typeof documents["\n query CharacterQuery($characterId: ID!) @live {\n character(id: $characterId) {\n id\n ...CharacterViewFragment\n ...CharacterOverlayFragment\n }\n }\n"]; +export function gql( + source: "\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n" +): typeof documents["\n query CharacterEditorQuery($editHash: ID!) @live {\n characterEditor(editHash: $editHash) {\n __typename\n ... on Error {\n reason\n }\n ... on CharacterEditorView {\n character {\n id\n ...CharacterViewFragment\n }\n }\n }\n }\n"]; +export function gql( + source: "\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n" +): typeof documents["\n mutation UpdateCharacterMutation($input: UpdateCharacterInput!) {\n updateCharacter(input: $input)\n }\n"]; +export function gql( + source: "\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n" +): typeof documents["\n fragment CharacterViewFragment on Character {\n id\n name\n imageUrl\n maximumHealth\n currentHealth\n hasMana\n maximumMana\n currentMana\n hasFatePoints\n maximumFatePoints\n currentFatePoints\n }\n"]; +export function gql( + source: "\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n" +): typeof documents["\n fragment CharacterOverlayFragment on Character {\n id\n name\n currentHealth\n maximumHealth\n hasMana\n currentMana\n maximumMana\n hasFatePoints\n currentFatePoints\n maximumFatePoints\n imageUrl\n }\n"]; +export function gql( + source: "\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n" +): typeof documents["\n mutation CreateCharacterMutation {\n createCharacter {\n __typename\n ... on Error {\n reason\n }\n ... on CreateCharacterSuccess {\n editHash\n }\n }\n }\n"]; export function gql(source: string): unknown; export function gql(source: string) { return (documents as any)[source] ?? {}; } -export type DocumentType> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never; \ No newline at end of file +export type DocumentType> = + TDocumentNode extends DocumentNode ? TType : never; diff --git a/src/gql/index.ts b/src/gql/index.ts index 407a4706..b3c7f85b 100644 --- a/src/gql/index.ts +++ b/src/gql/index.ts @@ -1,2 +1,2 @@ -export * from "./gql" -export * from "./fragment-masking" \ No newline at end of file +export * from "./gql"; +export * from "./fragment-masking";