diff --git a/examples/typescript-node/package.json b/examples/typescript-node/package.json index 211ad110..cb78796e 100644 --- a/examples/typescript-node/package.json +++ b/examples/typescript-node/package.json @@ -1,6 +1,6 @@ { "name": "typescript-node", - "version": "1.1.1", + "version": "1.1.2", "description": "", "private": true, "main": "index.js", diff --git a/examples/typescript-node/src/zeus/const.ts b/examples/typescript-node/src/zeus/const.ts index 9cf835ae..fe863f48 100644 --- a/examples/typescript-node/src/zeus/const.ts +++ b/examples/typescript-node/src/zeus/const.ts @@ -2,8 +2,11 @@ export const AllTypesProps: Record = { JSON: `scalar.JSON` as const, - Public:{ - powerups:{ + createCard:{ + skills:"SpecialSkills" + }, + Query:{ + cardById:{ } }, @@ -12,59 +15,63 @@ export const AllTypesProps: Record = { card:"createCard" } }, - createCard:{ - skills:"SpecialSkills" + Public:{ + powerups:{ + + } }, Card:{ attack:{ } }, - SpecialSkills: "enum" as const, - Query:{ - cardById:{ - - } - } + SpecialSkills: "enum" as const } export const ReturnTypes: Record = { + Powerup:{ + name:"String" + }, Nameable:{ - "...on CardStack": "CardStack", - "...on EffectCard": "EffectCard", "...on SpecialCard": "SpecialCard", + "...on EffectCard": "EffectCard", "...on Card": "Card", + "...on CardStack": "CardStack", name:"String" }, - ChangeCard:{ - "...on SpecialCard":"SpecialCard", - "...on EffectCard":"EffectCard" - }, - Subscription:{ - deck:"Card" - }, - Powerup:{ - name:"String" - }, - JSON: `scalar.JSON` as const, - CardStack:{ - cards:"Card", + SpecialCard:{ + effect:"String", name:"String" }, EffectCard:{ effectSize:"Float", name:"String" }, - SpecialCard:{ - effect:"String", - name:"String" + JSON: `scalar.JSON` as const, + ChangeCard:{ + "...on SpecialCard":"SpecialCard", + "...on EffectCard":"EffectCard" }, - Public:{ - powerups:"Powerup" + Query:{ + cardById:"Card", + drawCard:"Card", + drawChangeCard:"ChangeCard", + listCards:"Card", + myStacks:"CardStack", + nameables:"Nameable", + public:"Public" + }, + S3Object:{ + bucket:"String", + key:"String", + region:"String" }, Mutation:{ addCard:"Card" }, + Public:{ + powerups:"Powerup" + }, Card:{ Attack:"Int", Children:"Int", @@ -78,19 +85,12 @@ export const ReturnTypes: Record = { name:"String", skills:"SpecialSkills" }, - Query:{ - cardById:"Card", - drawCard:"Card", - drawChangeCard:"ChangeCard", - listCards:"Card", - myStacks:"CardStack", - nameables:"Nameable", - public:"Public" + Subscription:{ + deck:"Card" }, - S3Object:{ - bucket:"String", - key:"String", - region:"String" + CardStack:{ + cards:"Card", + name:"String" } } diff --git a/examples/typescript-node/src/zeus/index.ts b/examples/typescript-node/src/zeus/index.ts index d1456291..65d1c77d 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.js'; +import { AllTypesProps, ReturnTypes, Ops } from './const'; import fetch, { Response } from 'node-fetch'; import WebSocket from 'ws'; export const HOST = "https://faker.graphqleditor.com/a-team/olympus/graphql" @@ -164,7 +164,10 @@ export const Thunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: Record }) => + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: Record }, + ) => fn( Zeus(operation, o, { operationOptions: ops, @@ -193,7 +196,10 @@ export const SubscriptionThunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: ExtractVariables }) => { + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: ExtractVariables }, + ) => { const returnedFunction = fn( Zeus(operation, o, { operationOptions: ops, @@ -229,7 +235,7 @@ export const Zeus = < R extends keyof ValueTypes = GenericOperation, >( operation: O, - o: Z | ValueTypes[R], + o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { operationOptions?: OperationOptions; scalars?: ScalarDefinition; @@ -699,7 +705,7 @@ type IsInterfaced, DST, SCLR extends ScalarDefinition [P in keyof SRC]: SRC[P] extends '__union' & infer R ? P extends keyof DST ? IsArray - : IsArray + : IsArray, SCLR> : never; }[keyof SRC] & { [P in keyof Omit< @@ -833,30 +839,20 @@ export type ScalarCoders = { type ZEUS_UNIONS = GraphQLTypes["ChangeCard"] export type ValueTypes = { - ["Nameable"]:AliasType<{ + ["Powerup"]: AliasType<{ + name?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["Nameable"]:AliasType<{ name?:boolean | `@${string}`; - ['...on CardStack']?: Omit; - ['...on EffectCard']?: Omit; ['...on SpecialCard']?: Omit; + ['...on EffectCard']?: Omit; ['...on Card']?: Omit; + ['...on CardStack']?: Omit; __typename?: boolean | `@${string}` }>; - ["ChangeCard"]: AliasType<{ ["...on SpecialCard"] : ValueTypes["SpecialCard"], - ["...on EffectCard"] : ValueTypes["EffectCard"] - __typename?: boolean | `@${string}` -}>; - ["Subscription"]: AliasType<{ - deck?:ValueTypes["Card"], - __typename?: boolean | `@${string}` -}>; - ["Powerup"]: AliasType<{ - name?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["JSON"]:unknown; - /** Stack of cards */ -["CardStack"]: AliasType<{ - cards?:ValueTypes["Card"], + ["SpecialCard"]: AliasType<{ + effect?:boolean | `@${string}`, name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; @@ -865,57 +861,26 @@ export type ValueTypes = { name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["SpecialCard"]: AliasType<{ - effect?:boolean | `@${string}`, - name?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["Public"]: AliasType<{ -powerups?: [{ filter: string | Variable},ValueTypes["Powerup"]], - __typename?: boolean | `@${string}` -}>; - ["Mutation"]: AliasType<{ -addCard?: [{ card: ValueTypes["createCard"] | Variable},ValueTypes["Card"]], + ["JSON"]:unknown; + ["ChangeCard"]: AliasType<{ ["...on SpecialCard"] : ValueTypes["SpecialCard"], + ["...on EffectCard"] : ValueTypes["EffectCard"] __typename?: boolean | `@${string}` }>; /** create card inputs
*/ ["createCard"]: { - /** The attack power
*/ - Attack: number | Variable, - /** The defense power
*/ - Defense: number | Variable, - /** input skills */ - skills?: Array | undefined | null | Variable, /** 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 -}; - /** Card used in card game
*/ -["Card"]: AliasType<{ + Children?: number | undefined | null | Variable, /** The attack power
*/ - Attack?:boolean | `@${string}`, - /**
How many children the greek god had
*/ - Children?:boolean | `@${string}`, + Attack: number | Variable, /** The defense power
*/ - Defense?:boolean | `@${string}`, -attack?: [{ /** Attacked card/card ids
*/ - cardID: Array | Variable},ValueTypes["Card"]], - /** Put your description here */ - cardImage?:ValueTypes["S3Object"], - /** Description of a card
*/ - description?:boolean | `@${string}`, - id?:boolean | `@${string}`, - image?:boolean | `@${string}`, - info?:boolean | `@${string}`, - /** The name of a card
*/ - name?:boolean | `@${string}`, - skills?:boolean | `@${string}`, - __typename?: boolean | `@${string}` -}>; - ["SpecialSkills"]:SpecialSkills; + Defense: number | Variable, + /** input skills */ + skills?: Array | undefined | null | Variable +}; ["Query"]: AliasType<{ cardById?: [{ cardId?: string | undefined | null | Variable},ValueTypes["Card"]], /** Draw a card
*/ @@ -934,71 +899,121 @@ cardById?: [{ cardId?: string | undefined | null | Variable},ValueT key?:boolean | `@${string}`, region?:boolean | `@${string}`, __typename?: boolean | `@${string}` -}> - } - -export type ResolverInputTypes = { - ["Nameable"]:AliasType<{ - name?:boolean | `@${string}`; - ['...on CardStack']?: Omit; - ['...on EffectCard']?: Omit; - ['...on SpecialCard']?: Omit; - ['...on Card']?: Omit; - __typename?: boolean | `@${string}` }>; - ["ChangeCard"]: AliasType<{ - SpecialCard?:ResolverInputTypes["SpecialCard"], - EffectCard?:ResolverInputTypes["EffectCard"], + ["Mutation"]: AliasType<{ +addCard?: [{ card: ValueTypes["createCard"] | Variable},ValueTypes["Card"]], __typename?: boolean | `@${string}` }>; - ["Subscription"]: AliasType<{ - deck?:ResolverInputTypes["Card"], + ["Public"]: AliasType<{ +powerups?: [{ filter: string | Variable},ValueTypes["Powerup"]], __typename?: boolean | `@${string}` }>; - ["Powerup"]: AliasType<{ + /** Card used in card game
*/ +["Card"]: AliasType<{ + /** The attack power
*/ + Attack?:boolean | `@${string}`, + /**
How many children the greek god had
*/ + Children?:boolean | `@${string}`, + /** The defense power
*/ + Defense?:boolean | `@${string}`, +attack?: [{ /** Attacked card/card ids
*/ + cardID: Array | Variable},ValueTypes["Card"]], + /** Put your description here */ + cardImage?:ValueTypes["S3Object"], + /** Description of a card
*/ + description?:boolean | `@${string}`, + id?:boolean | `@${string}`, + image?:boolean | `@${string}`, + info?:boolean | `@${string}`, + /** The name of a card
*/ name?:boolean | `@${string}`, + skills?:boolean | `@${string}`, + __typename?: boolean | `@${string}` +}>; + ["Subscription"]: AliasType<{ + deck?:ValueTypes["Card"], __typename?: boolean | `@${string}` }>; - ["JSON"]:unknown; /** Stack of cards */ ["CardStack"]: AliasType<{ - cards?:ResolverInputTypes["Card"], + cards?:ValueTypes["Card"], name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["EffectCard"]: AliasType<{ - effectSize?:boolean | `@${string}`, + ["SpecialSkills"]:SpecialSkills + } + +export type ResolverInputTypes = { + ["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}` }>; - ["Public"]: AliasType<{ -powerups?: [{ filter: string},ResolverInputTypes["Powerup"]], + ["EffectCard"]: AliasType<{ + effectSize?:boolean | `@${string}`, + name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["Mutation"]: AliasType<{ -addCard?: [{ card: ResolverInputTypes["createCard"]},ResolverInputTypes["Card"]], + ["JSON"]:unknown; + ["ChangeCard"]: AliasType<{ + SpecialCard?:ResolverInputTypes["SpecialCard"], + EffectCard?:ResolverInputTypes["EffectCard"], __typename?: boolean | `@${string}` }>; /** create card inputs
*/ ["createCard"]: { - /** 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, /**
How many children the greek god had
*/ - Children?: number | undefined | null + Children?: number | undefined | null, + /** The attack power
*/ + Attack: number, + /** The defense power
*/ + Defense: number, + /** input skills */ + skills?: Array | undefined | null }; + ["Query"]: AliasType<{ +cardById?: [{ cardId?: string | undefined | null},ResolverInputTypes["Card"]], + /** Draw a card
*/ + drawCard?:ResolverInputTypes["Card"], + drawChangeCard?:ResolverInputTypes["ChangeCard"], + /** list All Cards availble
*/ + listCards?:ResolverInputTypes["Card"], + myStacks?:ResolverInputTypes["CardStack"], + nameables?:ResolverInputTypes["Nameable"], + 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}` +}>; /** Card used in card game
*/ ["Card"]: AliasType<{ /** The attack power
*/ @@ -1021,26 +1036,17 @@ attack?: [{ /** Attacked card/card ids
*/ skills?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; - ["SpecialSkills"]:SpecialSkills; - ["Query"]: AliasType<{ -cardById?: [{ cardId?: string | undefined | null},ResolverInputTypes["Card"]], - /** Draw a card
*/ - drawCard?:ResolverInputTypes["Card"], - drawChangeCard?:ResolverInputTypes["ChangeCard"], - /** list All Cards availble
*/ - listCards?:ResolverInputTypes["Card"], - myStacks?:ResolverInputTypes["CardStack"], - nameables?:ResolverInputTypes["Nameable"], - public?:ResolverInputTypes["Public"], + ["Subscription"]: AliasType<{ + deck?:ResolverInputTypes["Card"], __typename?: boolean | `@${string}` }>; - /** Aws S3 File */ -["S3Object"]: AliasType<{ - bucket?:boolean | `@${string}`, - key?:boolean | `@${string}`, - region?:boolean | `@${string}`, + /** Stack of cards */ +["CardStack"]: AliasType<{ + cards?:ResolverInputTypes["Card"], + name?:boolean | `@${string}`, __typename?: boolean | `@${string}` }>; + ["SpecialSkills"]:SpecialSkills; ["schema"]: AliasType<{ query?:ResolverInputTypes["Query"], mutation?:ResolverInputTypes["Mutation"], @@ -1050,49 +1056,58 @@ cardById?: [{ cardId?: string | undefined | null},ResolverInputTypes["Card"]], } export type ModelTypes = { - ["Nameable"]: ModelTypes["CardStack"] | ModelTypes["EffectCard"] | ModelTypes["SpecialCard"] | ModelTypes["Card"]; - ["ChangeCard"]:ModelTypes["SpecialCard"] | ModelTypes["EffectCard"]; - ["Subscription"]: { - deck?: Array | undefined -}; - ["Powerup"]: { + ["Powerup"]: { name?: string | undefined }; - ["JSON"]:any; - /** Stack of cards */ -["CardStack"]: { - cards?: Array | undefined, + ["Nameable"]: ModelTypes["SpecialCard"] | ModelTypes["EffectCard"] | ModelTypes["Card"] | ModelTypes["CardStack"]; + ["SpecialCard"]: { + effect: string, name: string }; ["EffectCard"]: { effectSize: number, name: string }; - ["SpecialCard"]: { - effect: string, - name: string -}; - ["Public"]: { - powerups?: Array | undefined -}; - ["Mutation"]: { - /** add Card to Cards database
*/ - addCard: ModelTypes["Card"] -}; + ["JSON"]:any; + ["ChangeCard"]:ModelTypes["SpecialCard"] | ModelTypes["EffectCard"]; /** create card inputs
*/ ["createCard"]: { - /** 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, /**
How many children the greek god had
*/ - Children?: number | undefined + Children?: number | undefined, + /** The attack power
*/ + Attack: number, + /** The defense power
*/ + Defense: number, + /** input skills */ + skills?: Array | undefined +}; + ["Query"]: { + cardById?: ModelTypes["Card"] | undefined, + /** Draw a card
*/ + drawCard: ModelTypes["Card"], + drawChangeCard: ModelTypes["ChangeCard"], + /** list All Cards availble
*/ + listCards: Array, + myStacks?: Array | undefined, + 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 }; /** Card used in card game
*/ ["Card"]: { @@ -1115,24 +1130,15 @@ export type ModelTypes = { name: string, skills?: Array | undefined }; - ["SpecialSkills"]:SpecialSkills; - ["Query"]: { - cardById?: ModelTypes["Card"] | undefined, - /** Draw a card
*/ - drawCard: ModelTypes["Card"], - drawChangeCard: ModelTypes["ChangeCard"], - /** list All Cards availble
*/ - listCards: Array, - myStacks?: Array | undefined, - nameables: Array, - public?: ModelTypes["Public"] | undefined + ["Subscription"]: { + deck?: Array | undefined }; - /** Aws S3 File */ -["S3Object"]: { - bucket: string, - key: string, - region: string + /** Stack of cards */ +["CardStack"]: { + cards?: Array | undefined, + name: string }; + ["SpecialSkills"]:SpecialSkills; ["schema"]: { query?: ModelTypes["Query"] | undefined, mutation?: ModelTypes["Mutation"] | undefined, @@ -1141,91 +1147,49 @@ export type ModelTypes = { } export type GraphQLTypes = { - ["Nameable"]: { - __typename:"CardStack" | "EffectCard" | "SpecialCard" | "Card", - name: string - ['...on CardStack']: '__union' & GraphQLTypes["CardStack"]; - ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; - ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; - ['...on Card']: '__union' & GraphQLTypes["Card"]; -}; - ["ChangeCard"]:{ - __typename:"SpecialCard" | "EffectCard" - ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; - ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; -}; - ["Subscription"]: { - __typename: "Subscription", - deck?: Array | undefined -}; - ["Powerup"]: { + ["Powerup"]: { __typename: "Powerup", name?: string | undefined }; - ["JSON"]: "scalar" & { name: "JSON" }; - /** Stack of cards */ -["CardStack"]: { - __typename: "CardStack", - cards?: Array | undefined, - name: string -}; - ["EffectCard"]: { - __typename: "EffectCard", - effectSize: number, + ["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 }; - ["Public"]: { - __typename: "Public", - powerups?: Array | undefined + ["EffectCard"]: { + __typename: "EffectCard", + effectSize: number, + name: string }; - ["Mutation"]: { - __typename: "Mutation", - /** add Card to Cards database
*/ - addCard: GraphQLTypes["Card"] + ["JSON"]: "scalar" & { name: "JSON" }; + ["ChangeCard"]:{ + __typename:"SpecialCard" | "EffectCard" + ['...on SpecialCard']: '__union' & GraphQLTypes["SpecialCard"]; + ['...on EffectCard']: '__union' & GraphQLTypes["EffectCard"]; }; /** create card inputs
*/ ["createCard"]: { - /** The attack power
*/ - Attack: number, - /** The defense power
*/ - Defense: number, - /** input skills */ - skills?: Array | undefined, - /** The name of a card
*/ + /** The name of a card
*/ name: string, /** Description of a card
*/ description: string, /**
How many children the greek god had
*/ - Children?: number | undefined -}; - /** Card used in card game
*/ -["Card"]: { - __typename: "Card", + Children?: number | undefined, /** The attack power
*/ Attack: number, - /**
How many children the greek god had
*/ - Children?: number | undefined, /** The defense power
*/ Defense: number, - /** Attack other cards on the table , returns Cards after attack
*/ - attack?: Array | undefined, - /** Put your description here */ - cardImage?: GraphQLTypes["S3Object"] | undefined, - /** Description of a card
*/ - description: string, - id: string, - image: string, - info: GraphQLTypes["JSON"], - /** The name of a card
*/ - name: string, + /** input skills */ skills?: Array | undefined }; - ["SpecialSkills"]: SpecialSkills; ["Query"]: { __typename: "Query", cardById?: GraphQLTypes["Card"] | undefined, @@ -1244,12 +1208,54 @@ export type GraphQLTypes = { bucket: string, key: string, region: string -} +}; + ["Mutation"]: { + __typename: "Mutation", + /** add Card to Cards database
*/ + addCard: GraphQLTypes["Card"] +}; + ["Public"]: { + __typename: "Public", + powerups?: Array | undefined +}; + /** Card used in card game
*/ +["Card"]: { + __typename: "Card", + /** The attack power
*/ + Attack: number, + /**
How many children the greek god had
*/ + Children?: number | undefined, + /** The defense power
*/ + Defense: number, + /** Attack other cards on the table , returns Cards after attack
*/ + attack?: Array | undefined, + /** Put your description here */ + cardImage?: GraphQLTypes["S3Object"] | undefined, + /** Description of a card
*/ + description: string, + id: string, + image: string, + info: GraphQLTypes["JSON"], + /** The name of a card
*/ + name: string, + skills?: Array | undefined +}; + ["Subscription"]: { + __typename: "Subscription", + deck?: Array | undefined +}; + /** Stack of cards */ +["CardStack"]: { + __typename: "CardStack", + cards?: Array | undefined, + name: string +}; + ["SpecialSkills"]: SpecialSkills } export const enum SpecialSkills { + THUNDER = "THUNDER", RAIN = "RAIN", - FIRE = "FIRE", - THUNDER = "THUNDER" + FIRE = "FIRE" } type ZEUS_VARIABLES = { diff --git a/examples/typescript-node/src/zeus/typedDocumentNode.ts b/examples/typescript-node/src/zeus/typedDocumentNode.ts index d457da69..2bee6d1d 100644 --- a/examples/typescript-node/src/zeus/typedDocumentNode.ts +++ b/examples/typescript-node/src/zeus/typedDocumentNode.ts @@ -18,7 +18,7 @@ export const typedGql = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions) => { + (o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: OperationOptions) => { const str = Zeus(operation, o, { operationOptions: ops, scalars: graphqlOptions?.scalars, diff --git a/examples/typescript-node/zeus.graphql b/examples/typescript-node/zeus.graphql index 3fbb00a1..35ec67b4 100644 --- a/examples/typescript-node/zeus.graphql +++ b/examples/typescript-node/zeus.graphql @@ -1,18 +1,3 @@ -"""""" -interface Nameable { - """""" - name: String! -} - -"""""" -union ChangeCard = SpecialCard | EffectCard - -"""""" -type Subscription { - """""" - deck: [Card!] -} - """""" type Powerup { """""" @@ -20,49 +5,46 @@ type Powerup { } """""" -scalar JSON - -"""Stack of cards""" -type CardStack implements Nameable { - """""" - cards: [Card!] - +interface Nameable { """""" name: String! } """""" -type EffectCard implements Nameable { +type SpecialCard implements Nameable { """""" - effectSize: Float! + effect: String! """""" name: String! } """""" -type SpecialCard implements Nameable { +type EffectCard implements Nameable { """""" - effect: String! + effectSize: Float! """""" name: String! } """""" -type Public { - """""" - powerups(filter: String!): [Powerup!] -} +scalar JSON """""" -type Mutation { - """add Card to Cards database
""" - addCard(card: createCard!): Card! -} +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! @@ -71,15 +53,54 @@ input createCard { """input skills""" skills: [SpecialSkills!] +} - """The name of a card
""" - name: String! +"""""" +type Query { + """""" + cardById(cardId: String): Card - """Description of a card
""" - description: String! + """Draw a card
""" + drawCard: Card! - """
How many children the greek god had
""" - Children: Int + """""" + drawChangeCard: ChangeCard! + + """list All Cards availble
""" + listCards: [Card!]! + + """""" + myStacks: [CardStack!] + + """""" + nameables: [Nameable!]! + + """""" + public: Public +} + +"""Aws S3 File""" +type S3Object { + """""" + bucket: String! + + """""" + key: String! + + """""" + region: String! +} + +"""""" +type Mutation { + """add Card to Cards database
""" + addCard(card: createCard!): Card! +} + +"""""" +type Public { + """""" + powerups(filter: String!): [Powerup!] } """Card used in card game
""" @@ -122,51 +143,30 @@ type Card implements Nameable { } """""" -enum SpecialSkills { - """Attack multiple Cards at once
""" - RAIN - - """50% chance to avoid any attack
""" - FIRE - - """Lower enemy defense -5
""" - THUNDER -} - -"""""" -type Query { - """""" - cardById(cardId: String): Card - - """Draw a card
""" - drawCard: Card! - - """""" - drawChangeCard: ChangeCard! - - """list All Cards availble
""" - listCards: [Card!]! - +type Subscription { """""" - myStacks: [CardStack!] + deck: [Card!] +} +"""Stack of cards""" +type CardStack implements Nameable { """""" - nameables: [Nameable!]! + cards: [Card!] """""" - public: Public + name: String! } -"""Aws S3 File""" -type S3Object { - """""" - bucket: String! +"""""" +enum SpecialSkills { + """Lower enemy defense -5
""" + THUNDER - """""" - key: String! + """Attack multiple Cards at once
""" + RAIN - """""" - region: String! + """50% chance to avoid any attack
""" + FIRE } schema{ query: Query, diff --git a/package.json b/package.json index 3274b89e..71230bba 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "run-example-typescript-node": "./run-example.sh examples/typescript-node", "examples-generate": "npm run generate-typescript-node", "produce-lib": "ts-node libBuilder.ts && eslint packages/graphql-zeus-core/TreeToTS/functions/generated.ts --quiet --fix", - "generate-typescript-node": "node ./packages/graphql-zeus/lib/index.js https://faker.graphqleditor.com/a-team/olympus/graphql ./examples/typescript-node/src --n -g ./examples/typescript-node/zeus.graphql --apollo --reactQuery --stuccoSubscriptions --td", + "generate-typescript-node": "node ./packages/graphql-zeus/lib/index.js https://faker.graphqleditor.com/a-team/olympus/graphql ./examples/typescript-node/src --n -g ./examples/typescript-node/zeus.graphql --stuccoSubscriptions --td", "cli": "node ./packages/graphql-zeus/lib/index.js", "test": "jest" }, diff --git a/packages/graphql-zeus-core/TreeToTS/functions/generated.ts b/packages/graphql-zeus-core/TreeToTS/functions/generated.ts index b4d1cfc3..a7b4a76b 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/generated.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/generated.ts @@ -123,7 +123,10 @@ export const Thunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: Record }) => + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: Record }, + ) => fn( Zeus(operation, o, { operationOptions: ops, @@ -152,7 +155,10 @@ export const SubscriptionThunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: ExtractVariables }) => { + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: ExtractVariables }, + ) => { const returnedFunction = fn( Zeus(operation, o, { operationOptions: ops, @@ -188,7 +194,7 @@ export const Zeus = < R extends keyof ValueTypes = GenericOperation, >( operation: O, - o: Z | ValueTypes[R], + o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { operationOptions?: OperationOptions; scalars?: ScalarDefinition; @@ -658,7 +664,7 @@ type IsInterfaced, DST, SCLR extends ScalarDefinition [P in keyof SRC]: SRC[P] extends '__union' & infer R ? P extends keyof DST ? IsArray - : IsArray + : IsArray, SCLR> : never; }[keyof SRC] & { [P in keyof Omit< diff --git a/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts b/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts index 2b605249..b83b0925 100644 --- a/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts +++ b/packages/graphql-zeus-core/TreeToTS/functions/new/clientFunctions.ts @@ -30,7 +30,10 @@ export const Thunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: Record }) => + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: Record }, + ) => fn( Zeus(operation, o, { operationOptions: ops, @@ -59,7 +62,10 @@ export const SubscriptionThunder = operation: O, graphqlOptions?: ThunderGraphQLOptions, ) => - (o: Z | ValueTypes[R], ops?: OperationOptions & { variables?: ExtractVariables }) => { + ( + o: (Z & ValueTypes[R]) | ValueTypes[R], + ops?: OperationOptions & { variables?: ExtractVariables }, + ) => { const returnedFunction = fn( Zeus(operation, o, { operationOptions: ops, @@ -95,7 +101,7 @@ export const Zeus = < R extends keyof ValueTypes = GenericOperation, >( operation: O, - o: Z | ValueTypes[R], + o: (Z & ValueTypes[R]) | ValueTypes[R], ops?: { operationOptions?: OperationOptions; scalars?: ScalarDefinition; diff --git a/packages/graphql-zeus-core/package.json b/packages/graphql-zeus-core/package.json index c1240377..69e205b3 100644 --- a/packages/graphql-zeus-core/package.json +++ b/packages/graphql-zeus-core/package.json @@ -1,6 +1,6 @@ { "name": "graphql-zeus-core", - "version": "5.3.1", + "version": "5.3.2", "private": false, "main": "./lib/index.js", "author": "GraphQL Editor, Artur Czemiel", diff --git a/packages/graphql-zeus-jsonschema/package.json b/packages/graphql-zeus-jsonschema/package.json index 672b8b78..b9887cb6 100644 --- a/packages/graphql-zeus-jsonschema/package.json +++ b/packages/graphql-zeus-jsonschema/package.json @@ -1,6 +1,6 @@ { "name": "graphql-zeus-jsonschema", - "version": "5.3.1", + "version": "5.3.2", "private": false, "main": "./lib/index.js", "author": "GraphQL Editor, Artur Czemiel", diff --git a/packages/graphql-zeus/package.json b/packages/graphql-zeus/package.json index 713b2f9b..81bc6a4a 100644 --- a/packages/graphql-zeus/package.json +++ b/packages/graphql-zeus/package.json @@ -1,6 +1,6 @@ { "name": "graphql-zeus", - "version": "5.3.1", + "version": "5.3.2", "private": false, "scripts": { "start": "ttsc --build tsconfig.build.json --watch", @@ -24,8 +24,8 @@ }, "dependencies": { "cross-fetch": "^3.0.4", - "graphql-zeus-core": "^5.3.1", - "graphql-zeus-jsonschema": "^5.3.1", + "graphql-zeus-core": "^5.3.2", + "graphql-zeus-jsonschema": "^5.3.2", "yargs": "^16.1.1" } }