diff --git a/examples/example-pokemon-api/package.json b/examples/example-pokemon-api/package.json index c8cdc0f8..ea352aea 100644 --- a/examples/example-pokemon-api/package.json +++ b/examples/example-pokemon-api/package.json @@ -13,7 +13,7 @@ "urql": "^4.0.6" }, "devDependencies": { - "@0no-co/graphqlsp": "^1.0.5", + "@0no-co/graphqlsp": "^1.1.2", "@types/react": "^18.2.47", "@types/react-dom": "^18.2.18", "@vitejs/plugin-react": "^4.2.1", diff --git a/examples/example-pokemon-api/schema/schema.graphql b/examples/example-pokemon-api/schema.graphql similarity index 100% rename from examples/example-pokemon-api/schema/schema.graphql rename to examples/example-pokemon-api/schema.graphql diff --git a/examples/example-pokemon-api/schema/graphql-env.d.ts b/examples/example-pokemon-api/schema/graphql-env.d.ts deleted file mode 100644 index 4b799e00..00000000 --- a/examples/example-pokemon-api/schema/graphql-env.d.ts +++ /dev/null @@ -1,434 +0,0 @@ -/** An IntrospectionQuery representation of your schema. - * - * @remarks - * This is an introspection of your schema saved as a file by GraphQLSP. - * It will automatically be used by `gql.tada` to infer the types of your GraphQL documents. - * If you need to reuse this data or update your `scalars`, update `tadaOutputLocation` to - * instead save to a .ts instead of a .d.ts file. - */ -export type introspection = { - __schema: { - queryType: { - name: 'Query'; - }; - mutationType: null; - subscriptionType: null; - types: [ - { - kind: 'OBJECT'; - name: 'Attack'; - fields: [ - { - name: 'damage'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - args: []; - }, - { - name: 'name'; - type: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - args: []; - }, - { - name: 'type'; - type: { - kind: 'ENUM'; - name: 'PokemonType'; - ofType: null; - }; - args: []; - }, - ]; - interfaces: []; - }, - { - kind: 'SCALAR'; - name: 'Int'; - }, - { - kind: 'SCALAR'; - name: 'String'; - }, - { - kind: 'OBJECT'; - name: 'AttacksConnection'; - fields: [ - { - name: 'fast'; - type: { - kind: 'LIST'; - ofType: { - kind: 'OBJECT'; - name: 'Attack'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'special'; - type: { - kind: 'LIST'; - ofType: { - kind: 'OBJECT'; - name: 'Attack'; - ofType: null; - }; - }; - args: []; - }, - ]; - interfaces: []; - }, - { - kind: 'OBJECT'; - name: 'EvolutionRequirement'; - fields: [ - { - name: 'amount'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - args: []; - }, - { - name: 'name'; - type: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - args: []; - }, - ]; - interfaces: []; - }, - { - kind: 'OBJECT'; - name: 'Pokemon'; - fields: [ - { - name: 'attacks'; - type: { - kind: 'OBJECT'; - name: 'AttacksConnection'; - ofType: null; - }; - args: []; - }, - { - name: 'classification'; - type: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - args: []; - }, - { - name: 'evolutionRequirements'; - type: { - kind: 'LIST'; - ofType: { - kind: 'OBJECT'; - name: 'EvolutionRequirement'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'evolutions'; - type: { - kind: 'LIST'; - ofType: { - kind: 'OBJECT'; - name: 'Pokemon'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'fleeRate'; - type: { - kind: 'SCALAR'; - name: 'Float'; - ofType: null; - }; - args: []; - }, - { - name: 'height'; - type: { - kind: 'OBJECT'; - name: 'PokemonDimension'; - ofType: null; - }; - args: []; - }, - { - name: 'id'; - type: { - kind: 'NON_NULL'; - ofType: { - kind: 'SCALAR'; - name: 'ID'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'maxCP'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - args: []; - }, - { - name: 'maxHP'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - args: []; - }, - { - name: 'name'; - type: { - kind: 'NON_NULL'; - ofType: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'resistant'; - type: { - kind: 'LIST'; - ofType: { - kind: 'ENUM'; - name: 'PokemonType'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'types'; - type: { - kind: 'LIST'; - ofType: { - kind: 'ENUM'; - name: 'PokemonType'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'weaknesses'; - type: { - kind: 'LIST'; - ofType: { - kind: 'ENUM'; - name: 'PokemonType'; - ofType: null; - }; - }; - args: []; - }, - { - name: 'weight'; - type: { - kind: 'OBJECT'; - name: 'PokemonDimension'; - ofType: null; - }; - args: []; - }, - ]; - interfaces: []; - }, - { - kind: 'SCALAR'; - name: 'Float'; - }, - { - kind: 'SCALAR'; - name: 'ID'; - }, - { - kind: 'OBJECT'; - name: 'PokemonDimension'; - fields: [ - { - name: 'maximum'; - type: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - args: []; - }, - { - name: 'minimum'; - type: { - kind: 'SCALAR'; - name: 'String'; - ofType: null; - }; - args: []; - }, - ]; - interfaces: []; - }, - { - kind: 'ENUM'; - name: 'PokemonType'; - enumValues: [ - { - name: 'Bug'; - }, - { - name: 'Dark'; - }, - { - name: 'Dragon'; - }, - { - name: 'Electric'; - }, - { - name: 'Fairy'; - }, - { - name: 'Fighting'; - }, - { - name: 'Fire'; - }, - { - name: 'Flying'; - }, - { - name: 'Ghost'; - }, - { - name: 'Grass'; - }, - { - name: 'Ground'; - }, - { - name: 'Ice'; - }, - { - name: 'Normal'; - }, - { - name: 'Poison'; - }, - { - name: 'Psychic'; - }, - { - name: 'Rock'; - }, - { - name: 'Steel'; - }, - { - name: 'Water'; - }, - ]; - }, - { - kind: 'OBJECT'; - name: 'Query'; - fields: [ - { - name: 'pokemon'; - type: { - kind: 'OBJECT'; - name: 'Pokemon'; - ofType: null; - }; - args: [ - { - name: 'id'; - type: { - kind: 'NON_NULL'; - ofType: { - kind: 'SCALAR'; - name: 'ID'; - ofType: null; - }; - }; - }, - ]; - }, - { - name: 'pokemons'; - type: { - kind: 'LIST'; - ofType: { - kind: 'OBJECT'; - name: 'Pokemon'; - ofType: null; - }; - }; - args: [ - { - name: 'limit'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - }, - { - name: 'skip'; - type: { - kind: 'SCALAR'; - name: 'Int'; - ofType: null; - }; - }, - ]; - }, - ]; - interfaces: []; - }, - { - kind: 'SCALAR'; - name: 'Boolean'; - }, - ]; - directives: []; - }; -}; - -import * as gqlTada from 'gql.tada'; - -declare module 'gql.tada' { - interface setupSchema { - introspection: introspection; - } -} diff --git a/examples/example-pokemon-api/schema/introspection.ts b/examples/example-pokemon-api/schema/introspection.ts deleted file mode 100644 index 2927c8fd..00000000 --- a/examples/example-pokemon-api/schema/introspection.ts +++ /dev/null @@ -1,441 +0,0 @@ -/** An IntrospectionQuery representation of your schema. - * - * @remarks - * This is an introspection of your schema saved as a file by GraphQLSP. - * You may import it to create a `graphql()` tag function with `gql.tada` - * by importing it and passing it to `initGraphQLTada<>()`. - * - * @example - * ``` - * import { initGraphQLTada } from 'gql.tada'; - * import type { introspection } from './introspection'; - * - * export const graphql = initGraphQLTada<{ - * introspection: typeof introspection; - * scalars: { - * DateTime: string; - * Json: any; - * }; - * }>(); - * ``` - */ -const introspection = { - __schema: { - queryType: { - name: 'Query', - }, - mutationType: null, - subscriptionType: null, - types: [ - { - kind: 'OBJECT', - name: 'Attack', - fields: [ - { - name: 'damage', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - args: [], - }, - { - name: 'name', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - args: [], - }, - { - name: 'type', - type: { - kind: 'ENUM', - name: 'PokemonType', - ofType: null, - }, - args: [], - }, - ], - interfaces: [], - }, - { - kind: 'SCALAR', - name: 'Int', - }, - { - kind: 'SCALAR', - name: 'String', - }, - { - kind: 'OBJECT', - name: 'AttacksConnection', - fields: [ - { - name: 'fast', - type: { - kind: 'LIST', - ofType: { - kind: 'OBJECT', - name: 'Attack', - ofType: null, - }, - }, - args: [], - }, - { - name: 'special', - type: { - kind: 'LIST', - ofType: { - kind: 'OBJECT', - name: 'Attack', - ofType: null, - }, - }, - args: [], - }, - ], - interfaces: [], - }, - { - kind: 'OBJECT', - name: 'EvolutionRequirement', - fields: [ - { - name: 'amount', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - args: [], - }, - { - name: 'name', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - args: [], - }, - ], - interfaces: [], - }, - { - kind: 'OBJECT', - name: 'Pokemon', - fields: [ - { - name: 'attacks', - type: { - kind: 'OBJECT', - name: 'AttacksConnection', - ofType: null, - }, - args: [], - }, - { - name: 'classification', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - args: [], - }, - { - name: 'evolutionRequirements', - type: { - kind: 'LIST', - ofType: { - kind: 'OBJECT', - name: 'EvolutionRequirement', - ofType: null, - }, - }, - args: [], - }, - { - name: 'evolutions', - type: { - kind: 'LIST', - ofType: { - kind: 'OBJECT', - name: 'Pokemon', - ofType: null, - }, - }, - args: [], - }, - { - name: 'fleeRate', - type: { - kind: 'SCALAR', - name: 'Float', - ofType: null, - }, - args: [], - }, - { - name: 'height', - type: { - kind: 'OBJECT', - name: 'PokemonDimension', - ofType: null, - }, - args: [], - }, - { - name: 'id', - type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'ID', - ofType: null, - }, - }, - args: [], - }, - { - name: 'maxCP', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - args: [], - }, - { - name: 'maxHP', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - args: [], - }, - { - name: 'name', - type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - }, - args: [], - }, - { - name: 'resistant', - type: { - kind: 'LIST', - ofType: { - kind: 'ENUM', - name: 'PokemonType', - ofType: null, - }, - }, - args: [], - }, - { - name: 'types', - type: { - kind: 'LIST', - ofType: { - kind: 'ENUM', - name: 'PokemonType', - ofType: null, - }, - }, - args: [], - }, - { - name: 'weaknesses', - type: { - kind: 'LIST', - ofType: { - kind: 'ENUM', - name: 'PokemonType', - ofType: null, - }, - }, - args: [], - }, - { - name: 'weight', - type: { - kind: 'OBJECT', - name: 'PokemonDimension', - ofType: null, - }, - args: [], - }, - ], - interfaces: [], - }, - { - kind: 'SCALAR', - name: 'Float', - }, - { - kind: 'SCALAR', - name: 'ID', - }, - { - kind: 'OBJECT', - name: 'PokemonDimension', - fields: [ - { - name: 'maximum', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - args: [], - }, - { - name: 'minimum', - type: { - kind: 'SCALAR', - name: 'String', - ofType: null, - }, - args: [], - }, - ], - interfaces: [], - }, - { - kind: 'ENUM', - name: 'PokemonType', - enumValues: [ - { - name: 'Bug', - }, - { - name: 'Dark', - }, - { - name: 'Dragon', - }, - { - name: 'Electric', - }, - { - name: 'Fairy', - }, - { - name: 'Fighting', - }, - { - name: 'Fire', - }, - { - name: 'Flying', - }, - { - name: 'Ghost', - }, - { - name: 'Grass', - }, - { - name: 'Ground', - }, - { - name: 'Ice', - }, - { - name: 'Normal', - }, - { - name: 'Poison', - }, - { - name: 'Psychic', - }, - { - name: 'Rock', - }, - { - name: 'Steel', - }, - { - name: 'Water', - }, - ], - }, - { - kind: 'OBJECT', - name: 'Query', - fields: [ - { - name: 'pokemon', - type: { - kind: 'OBJECT', - name: 'Pokemon', - ofType: null, - }, - args: [ - { - name: 'id', - type: { - kind: 'NON_NULL', - ofType: { - kind: 'SCALAR', - name: 'ID', - ofType: null, - }, - }, - }, - ], - }, - { - name: 'pokemons', - type: { - kind: 'LIST', - ofType: { - kind: 'OBJECT', - name: 'Pokemon', - ofType: null, - }, - }, - args: [ - { - name: 'limit', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - }, - { - name: 'skip', - type: { - kind: 'SCALAR', - name: 'Int', - ofType: null, - }, - }, - ], - }, - ], - interfaces: [], - }, - { - kind: 'SCALAR', - name: 'Boolean', - }, - ], - directives: [], - }, -} as const; - -export { introspection }; diff --git a/examples/example-pokemon-api/src/graphql-env.d.ts b/examples/example-pokemon-api/src/graphql-env.d.ts new file mode 100644 index 00000000..8d524386 --- /dev/null +++ b/examples/example-pokemon-api/src/graphql-env.d.ts @@ -0,0 +1,437 @@ +/* eslint-disable */ +/* prettier-ignore */ + +/** An IntrospectionQuery representation of your schema. + * + * @remarks + * This is an introspection of your schema saved as a file by GraphQLSP. + * It will automatically be used by `gql.tada` to infer the types of your GraphQL documents. + * If you need to reuse this data or update your `scalars`, update `tadaOutputLocation` to + * instead save to a .ts instead of a .d.ts file. + */ +export type introspection = { + "__schema": { + "queryType": { + "name": "Query" + }, + "mutationType": null, + "subscriptionType": null, + "types": [ + { + "kind": "OBJECT", + "name": "Attack", + "fields": [ + { + "name": "damage", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "args": [] + }, + { + "name": "name", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "args": [] + }, + { + "name": "type", + "type": { + "kind": "ENUM", + "name": "PokemonType", + "ofType": null + }, + "args": [] + } + ], + "interfaces": [] + }, + { + "kind": "SCALAR", + "name": "Int" + }, + { + "kind": "SCALAR", + "name": "String" + }, + { + "kind": "OBJECT", + "name": "AttacksConnection", + "fields": [ + { + "name": "fast", + "type": { + "kind": "LIST", + "ofType": { + "kind": "OBJECT", + "name": "Attack", + "ofType": null + } + }, + "args": [] + }, + { + "name": "special", + "type": { + "kind": "LIST", + "ofType": { + "kind": "OBJECT", + "name": "Attack", + "ofType": null + } + }, + "args": [] + } + ], + "interfaces": [] + }, + { + "kind": "OBJECT", + "name": "EvolutionRequirement", + "fields": [ + { + "name": "amount", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "args": [] + }, + { + "name": "name", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "args": [] + } + ], + "interfaces": [] + }, + { + "kind": "OBJECT", + "name": "Pokemon", + "fields": [ + { + "name": "attacks", + "type": { + "kind": "OBJECT", + "name": "AttacksConnection", + "ofType": null + }, + "args": [] + }, + { + "name": "classification", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "args": [] + }, + { + "name": "evolutionRequirements", + "type": { + "kind": "LIST", + "ofType": { + "kind": "OBJECT", + "name": "EvolutionRequirement", + "ofType": null + } + }, + "args": [] + }, + { + "name": "evolutions", + "type": { + "kind": "LIST", + "ofType": { + "kind": "OBJECT", + "name": "Pokemon", + "ofType": null + } + }, + "args": [] + }, + { + "name": "fleeRate", + "type": { + "kind": "SCALAR", + "name": "Float", + "ofType": null + }, + "args": [] + }, + { + "name": "height", + "type": { + "kind": "OBJECT", + "name": "PokemonDimension", + "ofType": null + }, + "args": [] + }, + { + "name": "id", + "type": { + "kind": "NON_NULL", + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + }, + "args": [] + }, + { + "name": "maxCP", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "args": [] + }, + { + "name": "maxHP", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "args": [] + }, + { + "name": "name", + "type": { + "kind": "NON_NULL", + "ofType": { + "kind": "SCALAR", + "name": "String", + "ofType": null + } + }, + "args": [] + }, + { + "name": "resistant", + "type": { + "kind": "LIST", + "ofType": { + "kind": "ENUM", + "name": "PokemonType", + "ofType": null + } + }, + "args": [] + }, + { + "name": "types", + "type": { + "kind": "LIST", + "ofType": { + "kind": "ENUM", + "name": "PokemonType", + "ofType": null + } + }, + "args": [] + }, + { + "name": "weaknesses", + "type": { + "kind": "LIST", + "ofType": { + "kind": "ENUM", + "name": "PokemonType", + "ofType": null + } + }, + "args": [] + }, + { + "name": "weight", + "type": { + "kind": "OBJECT", + "name": "PokemonDimension", + "ofType": null + }, + "args": [] + } + ], + "interfaces": [] + }, + { + "kind": "SCALAR", + "name": "Float" + }, + { + "kind": "SCALAR", + "name": "ID" + }, + { + "kind": "OBJECT", + "name": "PokemonDimension", + "fields": [ + { + "name": "maximum", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "args": [] + }, + { + "name": "minimum", + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "args": [] + } + ], + "interfaces": [] + }, + { + "kind": "ENUM", + "name": "PokemonType", + "enumValues": [ + { + "name": "Bug" + }, + { + "name": "Dark" + }, + { + "name": "Dragon" + }, + { + "name": "Electric" + }, + { + "name": "Fairy" + }, + { + "name": "Fighting" + }, + { + "name": "Fire" + }, + { + "name": "Flying" + }, + { + "name": "Ghost" + }, + { + "name": "Grass" + }, + { + "name": "Ground" + }, + { + "name": "Ice" + }, + { + "name": "Normal" + }, + { + "name": "Poison" + }, + { + "name": "Psychic" + }, + { + "name": "Rock" + }, + { + "name": "Steel" + }, + { + "name": "Water" + } + ] + }, + { + "kind": "OBJECT", + "name": "Query", + "fields": [ + { + "name": "pokemon", + "type": { + "kind": "OBJECT", + "name": "Pokemon", + "ofType": null + }, + "args": [ + { + "name": "id", + "type": { + "kind": "NON_NULL", + "ofType": { + "kind": "SCALAR", + "name": "ID", + "ofType": null + } + } + } + ] + }, + { + "name": "pokemons", + "type": { + "kind": "LIST", + "ofType": { + "kind": "OBJECT", + "name": "Pokemon", + "ofType": null + } + }, + "args": [ + { + "name": "limit", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + } + }, + { + "name": "skip", + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + } + } + ] + } + ], + "interfaces": [] + }, + { + "kind": "SCALAR", + "name": "Boolean" + } + ], + "directives": [] + } +}; + +import * as gqlTada from 'gql.tada'; + +declare module 'gql.tada' { + interface setupSchema { + introspection: introspection + } +} \ No newline at end of file diff --git a/examples/example-pokemon-api/src/graphql.ts b/examples/example-pokemon-api/src/graphql.ts index 6015a390..6f1dd3a9 100644 --- a/examples/example-pokemon-api/src/graphql.ts +++ b/examples/example-pokemon-api/src/graphql.ts @@ -1,5 +1,5 @@ import { initGraphQLTada } from 'gql.tada'; -import type { introspection } from '../schema/graphql-env.d.ts'; +import type { introspection } from './graphql-env.d.ts'; export const graphql = initGraphQLTada<{ introspection: introspection; diff --git a/examples/example-pokemon-api/tsconfig.json b/examples/example-pokemon-api/tsconfig.json index 9fc789e6..4bf76c2d 100644 --- a/examples/example-pokemon-api/tsconfig.json +++ b/examples/example-pokemon-api/tsconfig.json @@ -3,8 +3,8 @@ "plugins": [ { "name": "@0no-co/graphqlsp", - "schema": "./schema/schema.graphql", - "tadaOutputLocation": "./schema/graphql-env.d.ts" + "schema": "./schema.graphql", + "tadaOutputLocation": "./src/graphql-env.d.ts" } ], "noEmit": true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13940ce4..fd12a3ad 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -123,8 +123,8 @@ importers: version: 4.0.6(graphql@16.8.1)(react@18.2.0) devDependencies: '@0no-co/graphqlsp': - specifier: ^1.0.5 - version: 1.0.5 + specifier: ^1.1.2 + version: 1.1.2 '@types/react': specifier: ^18.2.47 version: 18.2.47 @@ -188,8 +188,8 @@ packages: graphql: 16.8.1 dev: false - /@0no-co/graphqlsp@1.0.5: - resolution: {integrity: sha512-R3INEWZlBDpCqDPreyVtC7sDgWydkz/3wUxB7KWXRCqkGEgcoDskfwOJnAyXXFcN9UQCypzkUvb1piRXAC1GdQ==} + /@0no-co/graphqlsp@1.1.2: + resolution: {integrity: sha512-qSRcMVBByfv06gpHeb0tuNb3ZNuqQZEpsQojoGDuOOJlXifBWPLbwNC2NwIvOUZN2zaSSuHrts7By0gVkiznfQ==} dependencies: node-fetch: 2.7.0 transitivePeerDependencies: