Skip to content

Commit

Permalink
chore(workspaace): add multi schema tests (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Apr 26, 2024
1 parent 474ca19 commit e314fd2
Show file tree
Hide file tree
Showing 16 changed files with 689 additions and 434 deletions.
46 changes: 34 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
@@ -0,0 +1,9 @@
import { initGraphQLTada } from 'gql.tada';
import type { introspection } from '../pokemons';

export const graphql = initGraphQLTada<{
introspection: introspection;
}>();

export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada';
export { readFragment } from 'gql.tada';
@@ -0,0 +1,15 @@
import { graphql } from './pokemon';

// prettier-ignore
const x = graphql(`
query Pokemons($limit: Int!) {
pokemons(limit: $limit) {
id
name
fleeRate
classification
__typename
}
}
`);
11 changes: 11 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/fixtures/simple-todo.ts
@@ -0,0 +1,11 @@
import { graphql } from './todo';

// prettier-ignore
const x = graphql(`
query Todo($id: ID!) {
todo(id: $id) {
id
}
}
`);
9 changes: 9 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/fixtures/todo.ts
@@ -0,0 +1,9 @@
import { initGraphQLTada } from 'gql.tada';
import type { introspection } from '../todos';

export const graphql = initGraphQLTada<{
introspection: introspection;
}>();

export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada';
export { readFragment } from 'gql.tada';
14 changes: 14 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/package.json
@@ -0,0 +1,14 @@
{
"name": "fixtures",
"private": true,
"dependencies": {
"graphql": "^16.0.0",
"gql.tada": "1.5.9-canary-8711af177005f46fa3e06d990b6ba28e353e7f9b",
"@graphql-typed-document-node/core": "^3.0.0",
"@0no-co/graphqlsp": "workspace:*",
"@urql/core": "^4.0.4"
},
"devDependencies": {
"typescript": "^5.3.3"
}
}
9 changes: 9 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/pokemon.ts
@@ -0,0 +1,9 @@
import { initGraphQLTada } from 'gql.tada';
import type { introspection } from './pokemons';

export const graphql = initGraphQLTada<{
introspection: introspection;
}>();

export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada';
export { readFragment } from 'gql.tada';
33 changes: 33 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/pokemons.d.ts
@@ -0,0 +1,33 @@
/* 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 = {
name: 'pokemons';
query: 'Query';
mutation: never;
subscription: never;
types: {
'Attack': { kind: 'OBJECT'; name: 'Attack'; fields: { 'damage': { name: 'damage'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; 'name': { name: 'name'; type: { kind: 'SCALAR'; name: 'String'; ofType: null; } }; 'type': { name: 'type'; type: { kind: 'ENUM'; name: 'PokemonType'; ofType: null; } }; }; };
'AttacksConnection': { kind: 'OBJECT'; name: 'AttacksConnection'; fields: { 'fast': { name: 'fast'; type: { kind: 'LIST'; name: never; ofType: { kind: 'OBJECT'; name: 'Attack'; ofType: null; }; } }; 'special': { name: 'special'; type: { kind: 'LIST'; name: never; ofType: { kind: 'OBJECT'; name: 'Attack'; ofType: null; }; } }; }; };
'Boolean': unknown;
'EvolutionRequirement': { kind: 'OBJECT'; name: 'EvolutionRequirement'; fields: { 'amount': { name: 'amount'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; 'name': { name: 'name'; type: { kind: 'SCALAR'; name: 'String'; ofType: null; } }; }; };
'Float': unknown;
'ID': unknown;
'Int': unknown;
'Pokemon': { kind: 'OBJECT'; name: 'Pokemon'; fields: { 'attacks': { name: 'attacks'; type: { kind: 'OBJECT'; name: 'AttacksConnection'; ofType: null; } }; 'classification': { name: 'classification'; type: { kind: 'SCALAR'; name: 'String'; ofType: null; } }; 'evolutionRequirements': { name: 'evolutionRequirements'; type: { kind: 'LIST'; name: never; ofType: { kind: 'OBJECT'; name: 'EvolutionRequirement'; ofType: null; }; } }; 'evolutions': { name: 'evolutions'; type: { kind: 'LIST'; name: never; ofType: { kind: 'OBJECT'; name: 'Pokemon'; ofType: null; }; } }; 'fleeRate': { name: 'fleeRate'; type: { kind: 'SCALAR'; name: 'Float'; ofType: null; } }; 'height': { name: 'height'; type: { kind: 'OBJECT'; name: 'PokemonDimension'; ofType: null; } }; 'id': { name: 'id'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'ID'; ofType: null; }; } }; 'maxCP': { name: 'maxCP'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; 'maxHP': { name: 'maxHP'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; 'name': { name: 'name'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'resistant': { name: 'resistant'; type: { kind: 'LIST'; name: never; ofType: { kind: 'ENUM'; name: 'PokemonType'; ofType: null; }; } }; 'types': { name: 'types'; type: { kind: 'LIST'; name: never; ofType: { kind: 'ENUM'; name: 'PokemonType'; ofType: null; }; } }; 'weaknesses': { name: 'weaknesses'; type: { kind: 'LIST'; name: never; ofType: { kind: 'ENUM'; name: 'PokemonType'; ofType: null; }; } }; 'weight': { name: 'weight'; type: { kind: 'OBJECT'; name: 'PokemonDimension'; ofType: null; } }; }; };
'PokemonDimension': { kind: 'OBJECT'; name: 'PokemonDimension'; fields: { 'maximum': { name: 'maximum'; type: { kind: 'SCALAR'; name: 'String'; ofType: null; } }; 'minimum': { name: 'minimum'; type: { kind: 'SCALAR'; name: 'String'; ofType: null; } }; }; };
'PokemonType': { name: 'PokemonType'; enumValues: 'Bug' | 'Dark' | 'Dragon' | 'Electric' | 'Fairy' | 'Fighting' | 'Fire' | 'Flying' | 'Ghost' | 'Grass' | 'Ground' | 'Ice' | 'Normal' | 'Poison' | 'Psychic' | 'Rock' | 'Steel' | 'Water'; };
'Query': { kind: 'OBJECT'; name: 'Query'; fields: { 'pokemon': { name: 'pokemon'; type: { kind: 'OBJECT'; name: 'Pokemon'; ofType: null; } }; 'pokemons': { name: 'pokemons'; type: { kind: 'LIST'; name: never; ofType: { kind: 'OBJECT'; name: 'Pokemon'; ofType: null; }; } }; }; };
'String': unknown;
};
};

import * as gqlTada from 'gql.tada';
94 changes: 94 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/pokemons.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/todo.ts
@@ -0,0 +1,10 @@
import { initGraphQLTada } from 'gql.tada';
// @ts-ignore
import type { introspection } from './todos';

export const graphql = initGraphQLTada<{
introspection: introspection;
}>();

export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada';
export { readFragment } from 'gql.tada';
26 changes: 26 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/todos.d.ts
@@ -0,0 +1,26 @@
/* 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 = {
name: 'todos';
query: 'Query';
mutation: never;
subscription: never;
types: {
'Boolean': unknown;
'ID': unknown;
'Query': { kind: 'OBJECT'; name: 'Query'; fields: { 'todo': { name: 'todo'; type: { kind: 'OBJECT'; name: 'Todo'; ofType: null; } }; }; };
'String': unknown;
'Todo': { kind: 'OBJECT'; name: 'Todo'; fields: { 'completed': { name: 'completed'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'id': { name: 'id'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'ID'; ofType: null; }; } }; 'text': { name: 'text'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; }; };
};
};

import * as gqlTada from 'gql.tada';
12 changes: 12 additions & 0 deletions test/e2e/fixture-project-tada-multi-schema/todos.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e314fd2

Please sign in to comment.