diff --git a/scripts/eslint-preset.js b/scripts/eslint-preset.js index 8f324a01..6bd354f4 100644 --- a/scripts/eslint-preset.js +++ b/scripts/eslint-preset.js @@ -8,7 +8,7 @@ module.exports = { }, extends: ['prettier'], plugins: ['prettier', 'tsdoc'], - ignorePatterns: ['node_modules/', 'dist/', 'coverage/', 'perf/'], + ignorePatterns: ['node_modules/', 'dist/', 'coverage/', 'perf/', 'fixtures'], rules: { 'no-undef': 'off', 'no-empty': 'off', diff --git a/src/__tests__/api.bench.ts b/src/__tests__/api.bench.ts index 7f8b87ec..d95cc7d1 100644 --- a/src/__tests__/api.bench.ts +++ b/src/__tests__/api.bench.ts @@ -10,7 +10,7 @@ describe('Document', () => { import { simpleIntrospection } from './simpleIntrospection'; import { ResultOf, initGraphQLTada, readFragment } from './api'; - const graphql = initGraphQLTada<{ introspection: typeof simpleIntrospection; }>(); + const graphql = initGraphQLTada<{ introspection: simpleIntrospection; }>(); const todoFragment = graphql(\` fragment TodoData on Todo { diff --git a/src/__tests__/api.test-d.ts b/src/__tests__/api.test-d.ts index d665b218..fa684023 100644 --- a/src/__tests__/api.test-d.ts +++ b/src/__tests__/api.test-d.ts @@ -20,7 +20,7 @@ type value = { __value: true }; type data = { __data: true }; describe('Public API', () => { - const graphql = initGraphQLTada<{ introspection: typeof simpleIntrospection }>(); + const graphql = initGraphQLTada<{ introspection: simpleIntrospection }>(); it('should create a fragment mask on masked fragments', () => { const fragment = graphql(` diff --git a/src/__tests__/api.test.ts b/src/__tests__/api.test.ts index d5647c2d..96110ff1 100644 --- a/src/__tests__/api.test.ts +++ b/src/__tests__/api.test.ts @@ -11,7 +11,7 @@ const testTypeHost = test.each([ describe('graphql function', () => { it('should strip @_unmask from fragment documents', () => { - const graphql = initGraphQLTada<{ introspection: typeof simpleIntrospection }>(); + const graphql = initGraphQLTada<{ introspection: simpleIntrospection }>(); const todoFragment = graphql(` fragment TodoData on Todo @_unmask { @@ -48,7 +48,7 @@ describe('declare setupSchema configuration', () => { declare module './api' { interface setupSchema { - introspection: typeof simpleIntrospection; + introspection: simpleIntrospection; } } @@ -115,7 +115,7 @@ describe('initGraphQLTada configuration', () => { import { ResultOf, FragmentOf, initGraphQLTada, readFragment } from './api'; import { $tada } from './namespace'; - const graphql = initGraphQLTada<{ introspection: typeof simpleIntrospection; }>(); + const graphql = initGraphQLTada<{ introspection: simpleIntrospection; }>(); const todoFragment = graphql(\` fragment TodoData on Todo { @@ -178,7 +178,7 @@ describe('initGraphQLTada configuration', () => { import { ResultOf, FragmentOf, initGraphQLTada, readFragment } from './api'; import { $tada } from './namespace'; - const graphql = initGraphQLTada<{ introspection: typeof simpleIntrospection; }>(); + const graphql = initGraphQLTada<{ introspection: simpleIntrospection; }>(); const todoFragment = graphql(\` fragment TodoData on Todo @_unmask { diff --git a/src/__tests__/fixtures/githubIntrospection.ts b/src/__tests__/fixtures/githubIntrospection.ts index eaa2e296..23b43b8c 100644 --- a/src/__tests__/fixtures/githubIntrospection.ts +++ b/src/__tests__/fixtures/githubIntrospection.ts @@ -1,4 +1,4 @@ -export const githubIntrospection = { +export type githubIntrospection = { __schema: { queryType: { name: 'Query', @@ -155821,4 +155821,4 @@ export const githubIntrospection = { }, ], }, -} as const; +}; diff --git a/src/__tests__/fixtures/simpleIntrospection.ts b/src/__tests__/fixtures/simpleIntrospection.ts index 48c8ba72..41dd613b 100644 --- a/src/__tests__/fixtures/simpleIntrospection.ts +++ b/src/__tests__/fixtures/simpleIntrospection.ts @@ -1,4 +1,4 @@ -export const simpleIntrospection = { +export type simpleIntrospection = { __schema: { queryType: { name: 'Query', @@ -588,4 +588,4 @@ export const simpleIntrospection = { }, ], }, -} as const; +}; diff --git a/src/__tests__/introspection.bench.ts b/src/__tests__/introspection.bench.ts index 976d4548..3f494cda 100644 --- a/src/__tests__/introspection.bench.ts +++ b/src/__tests__/introspection.bench.ts @@ -13,7 +13,7 @@ describe('Introspection', () => { import { simpleIntrospection } from './simpleIntrospection'; import { mapIntrospection } from './introspection'; - type schema = mapIntrospection; + type schema = mapIntrospection; `, }); @@ -38,7 +38,7 @@ describe('Introspection', () => { import { githubIntrospection } from './githubIntrospection'; import type { mapIntrospection } from './introspection'; - type schema = mapIntrospection; + type schema = mapIntrospection; `, }); diff --git a/src/__tests__/introspection.test-d.ts b/src/__tests__/introspection.test-d.ts index 6fb5a693..883ac348 100644 --- a/src/__tests__/introspection.test-d.ts +++ b/src/__tests__/introspection.test-d.ts @@ -4,12 +4,12 @@ import type { simpleSchema } from './fixtures/simpleSchema'; import type { mapIntrospection } from '../introspection'; test('prepares sample schema', () => { - type expected = mapIntrospection; + type expected = mapIntrospection; expectTypeOf().toMatchTypeOf(); }); test('applies scalar types as appropriate', () => { - type expected = mapIntrospection; + type expected = mapIntrospection; type idScalar = expected['types']['ID']['type']; expectTypeOf().toEqualTypeOf<'ID'>(); diff --git a/src/__tests__/selection.test-d.ts b/src/__tests__/selection.test-d.ts index 033aed9e..bb60eced 100644 --- a/src/__tests__/selection.test-d.ts +++ b/src/__tests__/selection.test-d.ts @@ -404,9 +404,7 @@ test('infers __typename on union unambiguously', () => { }); test('infers queries from GitHub introspection schema', () => { - type schema = mapIntrospection< - typeof import('./fixtures/githubIntrospection').githubIntrospection - >; + type schema = mapIntrospection; type repositories = parseDocument { } \`>; - type schema = mapIntrospection; + type schema = mapIntrospection; type actual = getDocumentType; expectTypeOf<{ @@ -85,7 +85,7 @@ describe('simple introspection', () => { } \`>; - type schema = mapIntrospection; + type schema = mapIntrospection; type actual = getDocumentType; expectTypeOf<{ diff --git a/src/__tests__/variables.test-d.ts b/src/__tests__/variables.test-d.ts index 6644af1d..9237d077 100644 --- a/src/__tests__/variables.test-d.ts +++ b/src/__tests__/variables.test-d.ts @@ -1,11 +1,8 @@ import { expectTypeOf, test } from 'vitest'; -import type { simpleIntrospection } from './fixtures/simpleIntrospection'; +import type { simpleSchema as schema } from './fixtures/simpleSchema'; import type { parseDocument } from '../parser'; -import type { mapIntrospection } from '../introspection'; import type { getVariablesType } from '../variables'; -type introspection = mapIntrospection; - test('parses document-variables correctly', () => { const query = ` mutation ($id: ID!) { @@ -14,7 +11,7 @@ test('parses document-variables correctly', () => { `; type doc = parseDocument; - type variables = getVariablesType; + type variables = getVariablesType; expectTypeOf().toEqualTypeOf<{ id: string | number }>(); }); @@ -27,7 +24,7 @@ test('works for input-objects', () => { `; type doc = parseDocument; - type variables = getVariablesType; + type variables = getVariablesType; expectTypeOf().toEqualTypeOf<{ id: string | number; @@ -43,7 +40,7 @@ test('allows optionals for default values', () => { `; type doc = parseDocument; - type variables = getVariablesType; + type variables = getVariablesType; expectTypeOf().toEqualTypeOf<{ id?: string | number | undefined }>(); expectTypeOf().toEqualTypeOf(); @@ -57,7 +54,7 @@ test('allows optionals for nullable values', () => { `; type doc = parseDocument; - type variables = getVariablesType; + type variables = getVariablesType; expectTypeOf().toEqualTypeOf<{ id?: string | number | null | undefined }>(); expectTypeOf().toEqualTypeOf();