From 05831f4c589f83b61646ada600209a3a2f949b56 Mon Sep 17 00:00:00 2001 From: Patrik Stutz Date: Tue, 21 Nov 2023 18:21:33 +0100 Subject: [PATCH 1/3] support exactOptionalPropertyTypes flag --- .../graphql-zeus-core/TreeToTS/functions/generated.ts | 8 ++++---- .../TreeToTS/functions/new/buildQuery.ts | 2 +- .../TreeToTS/functions/new/clientFunctions.ts | 4 ++-- .../TreeToTS/functions/new/resolvePath.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/graphql-zeus-core/TreeToTS/functions/generated.ts b/packages/graphql-zeus-core/TreeToTS/functions/generated.ts index a7b4a76b..e943e394 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/generated.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/generated.ts @@ -58,7 +58,7 @@ export const InternalsBuildQuery = ({ returns: ReturnTypesType; ops: Operations; options?: OperationOptions; - scalars?: ScalarDefinition; + scalars?: ScalarDefinition | undefined; }) => { const ibb = ( k: string, @@ -196,8 +196,8 @@ export const Zeus = < operation: O, o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { - operationOptions?: OperationOptions; - scalars?: ScalarDefinition; + operationOptions?: OperationOptions | undefined; + scalars?: ScalarDefinition | undefined; }, ) => InternalsBuildQuery({ @@ -558,7 +558,7 @@ export const InternalArgsBuilt = ({ props: AllTypesPropsType; returns: ReturnTypesType; ops: Operations; - scalars?: ScalarDefinition; + scalars?: ScalarDefinition | undefined; vars: Array<{ name: string; graphQLType: string }>; }) => { const arb = (a: ZeusArgsType, p = '', root = true): string => { diff --git a/packages/graphql-zeus-core/TreeToTS/functions/new/buildQuery.ts b/packages/graphql-zeus-core/TreeToTS/functions/new/buildQuery.ts index 8cf37006..9d681098 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/new/buildQuery.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/new/buildQuery.ts @@ -22,7 +22,7 @@ export const InternalsBuildQuery = ({ returns: ReturnTypesType; ops: Operations; options?: OperationOptions; - scalars?: ScalarDefinition; + scalars?: ScalarDefinition | undefined; }) => { const ibb = ( k: string, diff --git a/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts b/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts index b83b0925..9492f867 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts @@ -103,8 +103,8 @@ export const Zeus = < operation: O, o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { - operationOptions?: OperationOptions; - scalars?: ScalarDefinition; + operationOptions?: OperationOptions | undefined; + scalars?: ScalarDefinition | undefined; }, ) => InternalsBuildQuery({ diff --git a/packages/graphql-zeus-core/TreeToTS/functions/new/resolvePath.ts b/packages/graphql-zeus-core/TreeToTS/functions/new/resolvePath.ts index 245336ab..f62f72ed 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/new/resolvePath.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/new/resolvePath.ts @@ -108,7 +108,7 @@ export const InternalArgsBuilt = ({ props: AllTypesPropsType; returns: ReturnTypesType; ops: Operations; - scalars?: ScalarDefinition; + scalars?: ScalarDefinition | undefined; vars: Array<{ name: string; graphQLType: string }>; }) => { const arb = (a: ZeusArgsType, p = '', root = true): string => { From 8595a0a3bba177bdc51e5833b4d7bc89dfeee98b Mon Sep 17 00:00:00 2001 From: Patrik Stutz Date: Tue, 21 Nov 2023 18:21:48 +0100 Subject: [PATCH 2/3] enable exactOptionalPropertyTypes in TypeScript example --- examples/typescript-node/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/typescript-node/tsconfig.json b/examples/typescript-node/tsconfig.json index 7453461e..6a38058f 100644 --- a/examples/typescript-node/tsconfig.json +++ b/examples/typescript-node/tsconfig.json @@ -11,6 +11,7 @@ "removeComments": true, "noUnusedLocals": true, "strict": true, + "exactOptionalPropertyTypes": true, "outDir": "./lib", "rootDir": "./src", "baseUrl": "./src/" From c1260ee2db5a4313f50bd0bc103bd01ddb5a5c0c Mon Sep 17 00:00:00 2001 From: Patrik Stutz Date: Tue, 21 Nov 2023 18:22:06 +0100 Subject: [PATCH 3/3] update example --- examples/typescript-node/src/zeus/const.ts | 88 ++-- examples/typescript-node/src/zeus/index.ts | 454 ++++++++++----------- examples/typescript-node/zeus.graphql | 154 +++---- 3 files changed, 348 insertions(+), 348 deletions(-) diff --git a/examples/typescript-node/src/zeus/const.ts b/examples/typescript-node/src/zeus/const.ts index fe863f48..91a0d4d2 100644 --- a/examples/typescript-node/src/zeus/const.ts +++ b/examples/typescript-node/src/zeus/const.ts @@ -1,15 +1,20 @@ /* eslint-disable */ export const AllTypesProps: Record = { - JSON: `scalar.JSON` as const, + Query:{ + cardById:{ + + } + }, createCard:{ skills:"SpecialSkills" }, - Query:{ - cardById:{ + Card:{ + attack:{ } }, + JSON: `scalar.JSON` as const, Mutation:{ addCard:{ card:"createCard" @@ -20,38 +25,10 @@ export const AllTypesProps: Record = { } }, - Card:{ - attack:{ - - } - }, SpecialSkills: "enum" as const } export const ReturnTypes: Record = { - Powerup:{ - name:"String" - }, - Nameable:{ - "...on SpecialCard": "SpecialCard", - "...on EffectCard": "EffectCard", - "...on Card": "Card", - "...on CardStack": "CardStack", - name:"String" - }, - SpecialCard:{ - effect:"String", - name:"String" - }, - EffectCard:{ - effectSize:"Float", - name:"String" - }, - JSON: `scalar.JSON` as const, - ChangeCard:{ - "...on SpecialCard":"SpecialCard", - "...on EffectCard":"EffectCard" - }, Query:{ cardById:"Card", drawCard:"Card", @@ -61,17 +38,6 @@ export const ReturnTypes: Record = { nameables:"Nameable", public:"Public" }, - S3Object:{ - bucket:"String", - key:"String", - region:"String" - }, - Mutation:{ - addCard:"Card" - }, - Public:{ - powerups:"Powerup" - }, Card:{ Attack:"Int", Children:"Int", @@ -85,12 +51,46 @@ export const ReturnTypes: Record = { name:"String", skills:"SpecialSkills" }, - Subscription:{ - deck:"Card" + ChangeCard:{ + "...on SpecialCard":"SpecialCard", + "...on EffectCard":"EffectCard" + }, + EffectCard:{ + effectSize:"Float", + name:"String" + }, + Nameable:{ + "...on Card": "Card", + "...on EffectCard": "EffectCard", + "...on SpecialCard": "SpecialCard", + "...on CardStack": "CardStack", + name:"String" + }, + JSON: `scalar.JSON` as const, + SpecialCard:{ + effect:"String", + name:"String" }, CardStack:{ cards:"Card", name:"String" + }, + Powerup:{ + name:"String" + }, + Mutation:{ + addCard:"Card" + }, + Subscription:{ + deck:"Card" + }, + Public:{ + powerups:"Powerup" + }, + S3Object:{ + bucket:"String", + key:"String", + region:"String" } } diff --git a/examples/typescript-node/src/zeus/index.ts b/examples/typescript-node/src/zeus/index.ts index 65d1c77d..1a3fa966 100644 --- a/examples/typescript-node/src/zeus/index.ts +++ b/examples/typescript-node/src/zeus/index.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import { AllTypesProps, ReturnTypes, Ops } from './const'; +import { AllTypesProps, ReturnTypes, Ops } from './const.js'; import fetch, { Response } from 'node-fetch'; import WebSocket from 'ws'; export const HOST = "https://faker.graphqleditor.com/a-team/olympus/graphql" @@ -98,8 +98,8 @@ export const InternalsBuildQuery = ({ props: AllTypesPropsType; returns: ReturnTypesType; ops: Operations; - options?: OperationOptions; - scalars?: ScalarDefinition; + options?: OperationOptions | undefined; + scalars?: ScalarDefinition | undefined; }) => { const ibb = ( k: string, @@ -237,8 +237,8 @@ export const Zeus = < operation: O, o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { - operationOptions?: OperationOptions; - scalars?: ScalarDefinition; + operationOptions?: OperationOptions | undefined; + scalars?: ScalarDefinition | undefined; }, ) => InternalsBuildQuery({ @@ -599,7 +599,7 @@ export const InternalArgsBuilt = ({ props: AllTypesPropsType; returns: ReturnTypesType; ops: Operations; - scalars?: ScalarDefinition; + scalars?: ScalarDefinition | undefined; vars: Array<{ name: string; graphQLType: string }>; }) => { const arb = (a: ZeusArgsType, p = '', root = true): string => { @@ -839,39 +839,20 @@ export type ScalarCoders = { type ZEUS_UNIONS = GraphQLTypes["ChangeCard"] export type ValueTypes = { - ["Powerup"]: AliasType<{ - name?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["Nameable"]:AliasType<{ - name?:boolean | `@${string}`; - ['...on SpecialCard']?: Omit; - ['...on EffectCard']?: Omit; - ['...on Card']?: Omit; - ['...on CardStack']?: Omit; - __typename?: boolean | `@${string}` -}>; - ["SpecialCard"]: AliasType<{ - effect?:boolean | `@${string}`, - name?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["EffectCard"]: AliasType<{ - effectSize?:boolean | `@${string}`, - name?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["JSON"]:unknown; - ["ChangeCard"]: AliasType<{ ["...on SpecialCard"] : ValueTypes["SpecialCard"], - ["...on EffectCard"] : ValueTypes["EffectCard"] + ["Query"]: AliasType<{ +cardById?: [{ cardId?: string | undefined | null | Variable},ValueTypes["Card"]], + /** Draw a card
*/ + drawCard?:ValueTypes["Card"], + drawChangeCard?:ValueTypes["ChangeCard"], + /** list All Cards availble
*/ + listCards?:ValueTypes["Card"], + myStacks?:ValueTypes["CardStack"], + nameables?:ValueTypes["Nameable"], + public?:ValueTypes["Public"], __typename?: boolean | `@${string}` }>; /** create card inputs
*/ ["createCard"]: { - /** The name of a card
*/ - name: string | Variable, - /** Description of a card
*/ - description: string | Variable, /**
How many children the greek god had
*/ Children?: number | undefined | null | Variable, /** The attack power
*/ @@ -879,35 +860,12 @@ export type ValueTypes = { /** The defense power
*/ Defense: number | Variable, /** input skills */ - skills?: Array | undefined | null | Variable + skills?: Array | undefined | null | Variable, + /** The name of a card
*/ + name: string | Variable, + /** Description of a card
*/ + description: string | Variable }; - ["Query"]: AliasType<{ -cardById?: [{ cardId?: string | undefined | null | Variable},ValueTypes["Card"]], - /** Draw a card
*/ - drawCard?:ValueTypes["Card"], - drawChangeCard?:ValueTypes["ChangeCard"], - /** list All Cards availble
*/ - listCards?:ValueTypes["Card"], - myStacks?:ValueTypes["CardStack"], - nameables?:ValueTypes["Nameable"], - public?:ValueTypes["Public"], - __typename?: boolean | `@${string}` -}>; - /** Aws S3 File */ -["S3Object"]: AliasType<{ - bucket?:boolean | `@${string}`, - key?:boolean | `@${string}`, - region?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["Mutation"]: AliasType<{ -addCard?: [{ card: ValueTypes["createCard"] | Variable},ValueTypes["Card"]], - __typename?: boolean | `@${string}` -}>; - ["Public"]: AliasType<{ -powerups?: [{ filter: string | Variable},ValueTypes["Powerup"]], - __typename?: boolean | `@${string}` -}>; /** Card used in card game
*/ ["Card"]: AliasType<{ /** The attack power
*/ @@ -930,64 +888,63 @@ attack?: [{ /** Attacked card/card ids
*/ skills?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["Subscription"]: AliasType<{ - deck?:ValueTypes["Card"], - __typename?: boolean | `@${string}` -}>; - /** Stack of cards */ -["CardStack"]: AliasType<{ - cards?:ValueTypes["Card"], - name?:boolean | `@${string}`, + ["ChangeCard"]: AliasType<{ ["...on SpecialCard"] : ValueTypes["SpecialCard"], + ["...on EffectCard"] : ValueTypes["EffectCard"] __typename?: boolean | `@${string}` }>; - ["SpecialSkills"]:SpecialSkills - } - -export type ResolverInputTypes = { - ["Powerup"]: AliasType<{ + ["EffectCard"]: AliasType<{ + effectSize?:boolean | `@${string}`, name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; ["Nameable"]:AliasType<{ name?:boolean | `@${string}`; - ['...on SpecialCard']?: Omit; - ['...on EffectCard']?: Omit; - ['...on Card']?: Omit; - ['...on CardStack']?: Omit; + ['...on Card']?: Omit; + ['...on EffectCard']?: Omit; + ['...on SpecialCard']?: Omit; + ['...on CardStack']?: Omit; __typename?: boolean | `@${string}` }>; + ["JSON"]:unknown; ["SpecialCard"]: AliasType<{ effect?:boolean | `@${string}`, name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["EffectCard"]: AliasType<{ - effectSize?:boolean | `@${string}`, + /** Stack of cards */ +["CardStack"]: AliasType<{ + cards?:ValueTypes["Card"], name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["JSON"]:unknown; - ["ChangeCard"]: AliasType<{ - SpecialCard?:ResolverInputTypes["SpecialCard"], - EffectCard?:ResolverInputTypes["EffectCard"], + ["Powerup"]: AliasType<{ + name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - /** create card inputs
*/ -["createCard"]: { - /** The name of a card
*/ - name: string, - /** Description of a card
*/ - description: string, - /**
How many children the greek god had
*/ - Children?: number | undefined | null, - /** The attack power
*/ - Attack: number, - /** The defense power
*/ - Defense: number, - /** input skills */ - skills?: Array | undefined | null -}; - ["Query"]: AliasType<{ + ["Mutation"]: AliasType<{ +addCard?: [{ card: ValueTypes["createCard"] | Variable},ValueTypes["Card"]], + __typename?: boolean | `@${string}` +}>; + ["Subscription"]: AliasType<{ + deck?:ValueTypes["Card"], + __typename?: boolean | `@${string}` +}>; + ["Public"]: AliasType<{ +powerups?: [{ filter: string | Variable},ValueTypes["Powerup"]], + __typename?: boolean | `@${string}` +}>; + ["SpecialSkills"]:SpecialSkills; + /** Aws S3 File */ +["S3Object"]: AliasType<{ + bucket?:boolean | `@${string}`, + key?:boolean | `@${string}`, + region?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}> + } + +export type ResolverInputTypes = { + ["Query"]: AliasType<{ cardById?: [{ cardId?: string | undefined | null},ResolverInputTypes["Card"]], /** Draw a card
*/ drawCard?:ResolverInputTypes["Card"], @@ -999,21 +956,21 @@ cardById?: [{ cardId?: string | undefined | null},ResolverInputTypes["Card"]], public?:ResolverInputTypes["Public"], __typename?: boolean | `@${string}` }>; - /** Aws S3 File */ -["S3Object"]: AliasType<{ - bucket?:boolean | `@${string}`, - key?:boolean | `@${string}`, - region?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["Mutation"]: AliasType<{ -addCard?: [{ card: ResolverInputTypes["createCard"]},ResolverInputTypes["Card"]], - __typename?: boolean | `@${string}` -}>; - ["Public"]: AliasType<{ -powerups?: [{ filter: string},ResolverInputTypes["Powerup"]], - __typename?: boolean | `@${string}` -}>; + /** create card inputs
*/ +["createCard"]: { + /**
How many children the greek god had
*/ + Children?: number | undefined | null, + /** The attack power
*/ + Attack: number, + /** The defense power
*/ + Defense: number, + /** input skills */ + skills?: Array | undefined | null, + /** The name of a card
*/ + name: string, + /** Description of a card
*/ + description: string +}; /** Card used in card game
*/ ["Card"]: AliasType<{ /** The attack power
*/ @@ -1036,8 +993,28 @@ attack?: [{ /** Attacked card/card ids
*/ skills?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["Subscription"]: AliasType<{ - deck?:ResolverInputTypes["Card"], + ["ChangeCard"]: AliasType<{ + SpecialCard?:ResolverInputTypes["SpecialCard"], + EffectCard?:ResolverInputTypes["EffectCard"], + __typename?: boolean | `@${string}` +}>; + ["EffectCard"]: AliasType<{ + effectSize?:boolean | `@${string}`, + name?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["Nameable"]:AliasType<{ + name?:boolean | `@${string}`; + ['...on Card']?: Omit; + ['...on EffectCard']?: Omit; + ['...on SpecialCard']?: Omit; + ['...on CardStack']?: Omit; + __typename?: boolean | `@${string}` +}>; + ["JSON"]:unknown; + ["SpecialCard"]: AliasType<{ + effect?:boolean | `@${string}`, + name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; /** Stack of cards */ @@ -1045,8 +1022,31 @@ attack?: [{ /** Attacked card/card ids
*/ cards?:ResolverInputTypes["Card"], name?:boolean | `@${string}`, __typename?: boolean | `@${string}` +}>; + ["Powerup"]: AliasType<{ + name?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["Mutation"]: AliasType<{ +addCard?: [{ card: ResolverInputTypes["createCard"]},ResolverInputTypes["Card"]], + __typename?: boolean | `@${string}` +}>; + ["Subscription"]: AliasType<{ + deck?:ResolverInputTypes["Card"], + __typename?: boolean | `@${string}` +}>; + ["Public"]: AliasType<{ +powerups?: [{ filter: string},ResolverInputTypes["Powerup"]], + __typename?: boolean | `@${string}` }>; ["SpecialSkills"]:SpecialSkills; + /** Aws S3 File */ +["S3Object"]: AliasType<{ + bucket?:boolean | `@${string}`, + key?:boolean | `@${string}`, + region?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; ["schema"]: AliasType<{ query?:ResolverInputTypes["Query"], mutation?:ResolverInputTypes["Mutation"], @@ -1056,36 +1056,7 @@ attack?: [{ /** Attacked card/card ids
*/ } export type ModelTypes = { - ["Powerup"]: { - name?: string | undefined -}; - ["Nameable"]: ModelTypes["SpecialCard"] | ModelTypes["EffectCard"] | ModelTypes["Card"] | ModelTypes["CardStack"]; - ["SpecialCard"]: { - effect: string, - name: string -}; - ["EffectCard"]: { - effectSize: number, - name: string -}; - ["JSON"]:any; - ["ChangeCard"]:ModelTypes["SpecialCard"] | ModelTypes["EffectCard"]; - /** create card inputs
*/ -["createCard"]: { - /** The name of a card
*/ - name: string, - /** Description of a card
*/ - description: string, - /**
How many children the greek god had
*/ - Children?: number | undefined, - /** The attack power
*/ - Attack: number, - /** The defense power
*/ - Defense: number, - /** input skills */ - skills?: Array | undefined -}; - ["Query"]: { + ["Query"]: { cardById?: ModelTypes["Card"] | undefined, /** Draw a card
*/ drawCard: ModelTypes["Card"], @@ -1096,18 +1067,20 @@ export type ModelTypes = { nameables: Array, public?: ModelTypes["Public"] | undefined }; - /** Aws S3 File */ -["S3Object"]: { - bucket: string, - key: string, - region: string -}; - ["Mutation"]: { - /** add Card to Cards database
*/ - addCard: ModelTypes["Card"] -}; - ["Public"]: { - powerups?: Array | undefined + /** create card inputs
*/ +["createCard"]: { + /**
How many children the greek god had
*/ + Children?: number | undefined, + /** The attack power
*/ + Attack: number, + /** The defense power
*/ + Defense: number, + /** input skills */ + skills?: Array | undefined, + /** The name of a card
*/ + name: string, + /** Description of a card
*/ + description: string }; /** Card used in card game
*/ ["Card"]: { @@ -1130,15 +1103,42 @@ export type ModelTypes = { name: string, skills?: Array | undefined }; - ["Subscription"]: { - deck?: Array | undefined + ["ChangeCard"]:ModelTypes["SpecialCard"] | ModelTypes["EffectCard"]; + ["EffectCard"]: { + effectSize: number, + name: string +}; + ["Nameable"]: ModelTypes["Card"] | ModelTypes["EffectCard"] | ModelTypes["SpecialCard"] | ModelTypes["CardStack"]; + ["JSON"]:any; + ["SpecialCard"]: { + effect: string, + name: string }; /** Stack of cards */ ["CardStack"]: { cards?: Array | undefined, name: string +}; + ["Powerup"]: { + name?: string | undefined +}; + ["Mutation"]: { + /** add Card to Cards database
*/ + addCard: ModelTypes["Card"] +}; + ["Subscription"]: { + deck?: Array | undefined +}; + ["Public"]: { + powerups?: Array | undefined }; ["SpecialSkills"]:SpecialSkills; + /** Aws S3 File */ +["S3Object"]: { + bucket: string, + key: string, + region: string +}; ["schema"]: { query?: ModelTypes["Query"] | undefined, mutation?: ModelTypes["Mutation"] | undefined, @@ -1147,50 +1147,7 @@ export type ModelTypes = { } export type GraphQLTypes = { - ["Powerup"]: { - __typename: "Powerup", - name?: string | undefined -}; - ["Nameable"]: { - __typename:"SpecialCard" | "EffectCard" | "Card" | "CardStack", - name: string - ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; - ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; - ['...on Card']: '__union' & GraphQLTypes["Card"]; - ['...on CardStack']: '__union' & GraphQLTypes["CardStack"]; -}; - ["SpecialCard"]: { - __typename: "SpecialCard", - effect: string, - name: string -}; - ["EffectCard"]: { - __typename: "EffectCard", - effectSize: number, - name: string -}; - ["JSON"]: "scalar" & { name: "JSON" }; - ["ChangeCard"]:{ - __typename:"SpecialCard" | "EffectCard" - ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; - ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; -}; - /** create card inputs
*/ -["createCard"]: { - /** The name of a card
*/ - name: string, - /** Description of a card
*/ - description: string, - /**
How many children the greek god had
*/ - Children?: number | undefined, - /** The attack power
*/ - Attack: number, - /** The defense power
*/ - Defense: number, - /** input skills */ - skills?: Array | undefined -}; - ["Query"]: { + ["Query"]: { __typename: "Query", cardById?: GraphQLTypes["Card"] | undefined, /** Draw a card
*/ @@ -1202,21 +1159,20 @@ export type GraphQLTypes = { nameables: Array, public?: GraphQLTypes["Public"] | undefined }; - /** Aws S3 File */ -["S3Object"]: { - __typename: "S3Object", - bucket: string, - key: string, - region: string -}; - ["Mutation"]: { - __typename: "Mutation", - /** add Card to Cards database
*/ - addCard: GraphQLTypes["Card"] -}; - ["Public"]: { - __typename: "Public", - powerups?: Array | undefined + /** create card inputs
*/ +["createCard"]: { + /**
How many children the greek god had
*/ + Children?: number | undefined, + /** The attack power
*/ + Attack: number, + /** The defense power
*/ + Defense: number, + /** input skills */ + skills?: Array | undefined, + /** The name of a card
*/ + name: string, + /** Description of a card
*/ + description: string }; /** Card used in card game
*/ ["Card"]: { @@ -1240,9 +1196,29 @@ export type GraphQLTypes = { name: string, skills?: Array | undefined }; - ["Subscription"]: { - __typename: "Subscription", - deck?: Array | undefined + ["ChangeCard"]:{ + __typename:"SpecialCard" | "EffectCard" + ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; + ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; +}; + ["EffectCard"]: { + __typename: "EffectCard", + effectSize: number, + name: string +}; + ["Nameable"]: { + __typename:"Card" | "EffectCard" | "SpecialCard" | "CardStack", + name: string + ['...on Card']: '__union' & GraphQLTypes["Card"]; + ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; + ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; + ['...on CardStack']: '__union' & GraphQLTypes["CardStack"]; +}; + ["JSON"]: "scalar" & { name: "JSON" }; + ["SpecialCard"]: { + __typename: "SpecialCard", + effect: string, + name: string }; /** Stack of cards */ ["CardStack"]: { @@ -1250,7 +1226,31 @@ export type GraphQLTypes = { cards?: Array | undefined, name: string }; - ["SpecialSkills"]: SpecialSkills + ["Powerup"]: { + __typename: "Powerup", + name?: string | undefined +}; + ["Mutation"]: { + __typename: "Mutation", + /** add Card to Cards database
*/ + addCard: GraphQLTypes["Card"] +}; + ["Subscription"]: { + __typename: "Subscription", + deck?: Array | undefined +}; + ["Public"]: { + __typename: "Public", + powerups?: Array | undefined +}; + ["SpecialSkills"]: SpecialSkills; + /** Aws S3 File */ +["S3Object"]: { + __typename: "S3Object", + bucket: string, + key: string, + region: string +} } export const enum SpecialSkills { THUNDER = "THUNDER", @@ -1259,7 +1259,7 @@ export const enum SpecialSkills { } type ZEUS_VARIABLES = { - ["JSON"]: ValueTypes["JSON"]; ["createCard"]: ValueTypes["createCard"]; + ["JSON"]: ValueTypes["JSON"]; ["SpecialSkills"]: ValueTypes["SpecialSkills"]; } \ No newline at end of file diff --git a/examples/typescript-node/zeus.graphql b/examples/typescript-node/zeus.graphql index 35ec67b4..dc54a0bb 100644 --- a/examples/typescript-node/zeus.graphql +++ b/examples/typescript-node/zeus.graphql @@ -1,60 +1,3 @@ -"""""" -type Powerup { - """""" - name: String -} - -"""""" -interface Nameable { - """""" - name: String! -} - -"""""" -type SpecialCard implements Nameable { - """""" - effect: String! - - """""" - name: String! -} - -"""""" -type EffectCard implements Nameable { - """""" - effectSize: Float! - - """""" - name: String! -} - -"""""" -scalar JSON - -"""""" -union ChangeCard = SpecialCard | EffectCard - -"""create card inputs
""" -input createCard { - """The name of a card
""" - name: String! - - """Description of a card
""" - description: String! - - """
How many children the greek god had
""" - Children: Int - - """The attack power
""" - Attack: Int! - - """The defense power
""" - Defense: Int! - - """input skills""" - skills: [SpecialSkills!] -} - """""" type Query { """""" @@ -79,28 +22,25 @@ type Query { public: Public } -"""Aws S3 File""" -type S3Object { - """""" - bucket: String! +"""create card inputs
""" +input createCard { + """
How many children the greek god had
""" + Children: Int - """""" - key: String! + """The attack power
""" + Attack: Int! - """""" - region: String! -} + """The defense power
""" + Defense: Int! -"""""" -type Mutation { - """add Card to Cards database
""" - addCard(card: createCard!): Card! -} + """input skills""" + skills: [SpecialSkills!] -"""""" -type Public { - """""" - powerups(filter: String!): [Powerup!] + """The name of a card
""" + name: String! + + """Description of a card
""" + description: String! } """Card used in card game
""" @@ -143,9 +83,33 @@ type Card implements Nameable { } """""" -type Subscription { +union ChangeCard = SpecialCard | EffectCard + +"""""" +type EffectCard implements Nameable { """""" - deck: [Card!] + effectSize: Float! + + """""" + name: String! +} + +"""""" +interface Nameable { + """""" + name: String! +} + +"""""" +scalar JSON + +"""""" +type SpecialCard implements Nameable { + """""" + effect: String! + + """""" + name: String! } """Stack of cards""" @@ -157,6 +121,30 @@ type CardStack implements Nameable { name: String! } +"""""" +type Powerup { + """""" + name: String +} + +"""""" +type Mutation { + """add Card to Cards database
""" + addCard(card: createCard!): Card! +} + +"""""" +type Subscription { + """""" + deck: [Card!] +} + +"""""" +type Public { + """""" + powerups(filter: String!): [Powerup!] +} + """""" enum SpecialSkills { """Lower enemy defense -5
""" @@ -168,6 +156,18 @@ enum SpecialSkills { """50% chance to avoid any attack
""" FIRE } + +"""Aws S3 File""" +type S3Object { + """""" + bucket: String! + + """""" + key: String! + + """""" + region: String! +} schema{ query: Query, mutation: Mutation,