From 20c42e6bf24ac332306b92fa27938410ab6a7431 Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Sat, 6 May 2023 10:27:19 -0400 Subject: codegen --- src/main/webui/src/gql/conf/fragment-masking.ts | 44 ++++---- src/main/webui/src/gql/conf/gql.ts | 16 +++ src/main/webui/src/gql/conf/graphql.ts | 132 ++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 20 deletions(-) diff --git a/src/main/webui/src/gql/conf/fragment-masking.ts b/src/main/webui/src/gql/conf/fragment-masking.ts index 9881c7d..4bae142 100644 --- a/src/main/webui/src/gql/conf/fragment-masking.ts +++ b/src/main/webui/src/gql/conf/fragment-masking.ts @@ -1,46 +1,50 @@ /* eslint-disable */ import { ResultOf, - TypedDocumentNode as DocumentNode, + DocumentTypeDecoration, } from "@graphql-typed-document-node/core"; -export type FragmentType> = - TDocumentType extends DocumentNode - ? TType extends { " $fragmentName"?: infer TKey } - ? TKey extends string - ? { " $fragmentRefs"?: { [key in TKey]: TType } } - : never +export type FragmentType< + TDocumentType extends DocumentTypeDecoration, +> = TDocumentType extends DocumentTypeDecoration + ? TType extends { " $fragmentName"?: infer TKey } + ? TKey extends string + ? { " $fragmentRefs"?: { [key in TKey]: TType } } : never - : never; + : never + : never; // return non-nullable if `fragmentType` is non-nullable export function useFragment( - _documentNode: DocumentNode, - fragmentType: FragmentType>, + _documentNode: DocumentTypeDecoration, + fragmentType: FragmentType>, ): TType; // return nullable if `fragmentType` is nullable export function useFragment( - _documentNode: DocumentNode, - fragmentType: FragmentType> | null | undefined, + _documentNode: DocumentTypeDecoration, + fragmentType: + | FragmentType> + | null + | undefined, ): TType | null | undefined; // return array of non-nullable if `fragmentType` is array of non-nullable export function useFragment( - _documentNode: DocumentNode, - fragmentType: ReadonlyArray>>, + _documentNode: DocumentTypeDecoration, + fragmentType: ReadonlyArray>>, ): ReadonlyArray; // return array of nullable if `fragmentType` is array of nullable export function useFragment( - _documentNode: DocumentNode, + _documentNode: DocumentTypeDecoration, fragmentType: - | ReadonlyArray>> + | ReadonlyArray>> | null | undefined, ): ReadonlyArray | null | undefined; export function useFragment( - _documentNode: DocumentNode, + _documentNode: DocumentTypeDecoration, fragmentType: - | FragmentType> - | ReadonlyArray>> + | FragmentType> + | ReadonlyArray>> | null | undefined, ): TType | ReadonlyArray | null | undefined { @@ -48,7 +52,7 @@ export function useFragment( } export function makeFragmentData< - F extends DocumentNode, + F extends DocumentTypeDecoration, FT extends ResultOf, >(data: FT, _fragment: F): FragmentType { return data as FragmentType; diff --git a/src/main/webui/src/gql/conf/gql.ts b/src/main/webui/src/gql/conf/gql.ts index 80a0ed4..0f4ec68 100644 --- a/src/main/webui/src/gql/conf/gql.ts +++ b/src/main/webui/src/gql/conf/gql.ts @@ -18,6 +18,10 @@ const documents = { types.AllItemsDocument, "\n mutation storeItem(\n $id: String\n $name: String\n $description: String\n $quantity: Float!\n $quantityUnitType: String\n ) {\n storeItem(\n item: {\n id: $id\n name: $name\n description: $description\n quantity: $quantity\n quantityUnitType: $quantityUnitType\n }\n ) {\n id\n name\n description\n quantity\n quantityUnitType\n }\n }\n": types.StoreItemDocument, + "\n query allLabels {\n allLabels {\n id\n title\n color\n }\n }\n": + types.AllLabelsDocument, + "\n mutation syncLabels(\n $labels: [PantryItemLabelInput]\n ) {\n syncLabels(\n labels: $labels\n ) {\n id\n title\n color\n }\n }\n": + types.SyncLabelsDocument, }; /** @@ -46,6 +50,18 @@ export function graphql( export function graphql( source: "\n mutation storeItem(\n $id: String\n $name: String\n $description: String\n $quantity: Float!\n $quantityUnitType: String\n ) {\n storeItem(\n item: {\n id: $id\n name: $name\n description: $description\n quantity: $quantity\n quantityUnitType: $quantityUnitType\n }\n ) {\n id\n name\n description\n quantity\n quantityUnitType\n }\n }\n", ): (typeof documents)["\n mutation storeItem(\n $id: String\n $name: String\n $description: String\n $quantity: Float!\n $quantityUnitType: String\n ) {\n storeItem(\n item: {\n id: $id\n name: $name\n description: $description\n quantity: $quantity\n quantityUnitType: $quantityUnitType\n }\n ) {\n id\n name\n description\n quantity\n quantityUnitType\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: "\n query allLabels {\n allLabels {\n id\n title\n color\n }\n }\n", +): (typeof documents)["\n query allLabels {\n allLabels {\n id\n title\n color\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql( + source: "\n mutation syncLabels(\n $labels: [PantryItemLabelInput]\n ) {\n syncLabels(\n labels: $labels\n ) {\n id\n title\n color\n }\n }\n", +): (typeof documents)["\n mutation syncLabels(\n $labels: [PantryItemLabelInput]\n ) {\n syncLabels(\n labels: $labels\n ) {\n id\n title\n color\n }\n }\n"]; export function graphql(source: string) { return (documents as any)[source] ?? {}; diff --git a/src/main/webui/src/gql/conf/graphql.ts b/src/main/webui/src/gql/conf/graphql.ts index 2474e0f..8cf0870 100644 --- a/src/main/webui/src/gql/conf/graphql.ts +++ b/src/main/webui/src/gql/conf/graphql.ts @@ -27,6 +27,8 @@ export type Mutation = { deleteItem?: Maybe; /** Store an item in the pantry */ storeItem?: Maybe; + /** Create any new labels from list of labels */ + syncLabels?: Maybe>>; }; /** Mutation root */ @@ -39,10 +41,16 @@ export type MutationStoreItemArgs = { item?: InputMaybe; }; +/** Mutation root */ +export type MutationSyncLabelsArgs = { + labels?: InputMaybe>>; +}; + export type PantryItem = { __typename?: "PantryItem"; description?: Maybe; id?: Maybe; + labels?: Maybe>>; name?: Maybe; quantity: Scalars["Float"]; quantityUnitType?: Maybe; @@ -51,16 +59,32 @@ export type PantryItem = { export type PantryItemInput = { description?: InputMaybe; id?: InputMaybe; + labels?: InputMaybe>>; name?: InputMaybe; quantity: Scalars["Float"]; quantityUnitType?: InputMaybe; }; +export type PantryItemLabel = { + __typename?: "PantryItemLabel"; + color?: Maybe; + id?: Maybe; + title?: Maybe; +}; + +export type PantryItemLabelInput = { + color?: InputMaybe; + id?: InputMaybe; + title?: InputMaybe; +}; + /** Query root */ export type Query = { __typename?: "Query"; /** Get all items stored in the pantry */ allItems?: Maybe>>; + /** Get all labels that can be assigned to items */ + allLabels?: Maybe>>; /** Get an item stored in the pantry */ item?: Maybe; }; @@ -104,6 +128,34 @@ export type StoreItemMutation = { } | null; }; +export type AllLabelsQueryVariables = Exact<{ [key: string]: never }>; + +export type AllLabelsQuery = { + __typename?: "Query"; + allLabels?: Array<{ + __typename?: "PantryItemLabel"; + id?: string | null; + title?: string | null; + color?: string | null; + } | null> | null; +}; + +export type SyncLabelsMutationVariables = Exact<{ + labels?: InputMaybe< + Array> | InputMaybe + >; +}>; + +export type SyncLabelsMutation = { + __typename?: "Mutation"; + syncLabels?: Array<{ + __typename?: "PantryItemLabel"; + id?: string | null; + title?: string | null; + color?: string | null; + } | null> | null; +}; + export const AllItemsDocument = { kind: "Document", definitions: [ @@ -258,3 +310,83 @@ export const StoreItemDocument = { }, ], } as unknown as DocumentNode; +export const AllLabelsDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "query", + name: { kind: "Name", value: "allLabels" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "allLabels" }, + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { kind: "Field", name: { kind: "Name", value: "title" } }, + { kind: "Field", name: { kind: "Name", value: "color" } }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode; +export const SyncLabelsDocument = { + kind: "Document", + definitions: [ + { + kind: "OperationDefinition", + operation: "mutation", + name: { kind: "Name", value: "syncLabels" }, + variableDefinitions: [ + { + kind: "VariableDefinition", + variable: { + kind: "Variable", + name: { kind: "Name", value: "labels" }, + }, + type: { + kind: "ListType", + type: { + kind: "NamedType", + name: { kind: "Name", value: "PantryItemLabelInput" }, + }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { + kind: "Field", + name: { kind: "Name", value: "syncLabels" }, + arguments: [ + { + kind: "Argument", + name: { kind: "Name", value: "labels" }, + value: { + kind: "Variable", + name: { kind: "Name", value: "labels" }, + }, + }, + ], + selectionSet: { + kind: "SelectionSet", + selections: [ + { kind: "Field", name: { kind: "Name", value: "id" } }, + { kind: "Field", name: { kind: "Name", value: "title" } }, + { kind: "Field", name: { kind: "Name", value: "color" } }, + ], + }, + }, + ], + }, + }, + ], +} as unknown as DocumentNode; -- cgit