Skip to content

Commit

Permalink
chore: add test confirming v16 schema compat (#1054)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser authored Mar 5, 2022
1 parent bbc969a commit 92f20dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/definitions/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ export type NexusGraphQLInterfaceTypeConfig = WithExt<
> & { interfaces: () => GraphQLInterfaceType[] }

export interface NexusGraphQLSchema extends GraphQLSchema {
extensions: { nexus: NexusSchemaExtension }
extensions: {
nexus: NexusSchemaExtension
[attributeName: string]: unknown
}
}

export type NexusFeaturesInput = {
Expand Down
14 changes: 13 additions & 1 deletion tests/makeSchema.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { printSchema } from 'graphql'
import { GraphQLSchema, printSchema } from 'graphql'
import os from 'os'
import path from 'path'
import { objectType } from '../src'
Expand Down Expand Up @@ -151,4 +151,16 @@ describe('makeSchema', () => {
expect(tsTypes).toContain(`import type { Context } from "./makeSchema.spec"`)
})
})

it('is compatible with GraphQL schema types', () => {
const someFn = (schema: GraphQLSchema) => {
return schema.toConfig()
}

const nexusSchema = makeSchema({
types: [],
})

someFn(nexusSchema)
})
})
4 changes: 2 additions & 2 deletions tests/typegenPrinterGlobals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('typegenPrinter: globals', () => {
schema: path.join(__dirname, 'typegen-globals/schema.gen.graphql'),
} as const

const schema = (await generateSchema({
const schema = await generateSchema({
outputs,
shouldGenerateArtifacts: true,
types: [buildSchema(EXAMPLE_SDL)],
Expand All @@ -35,7 +35,7 @@ describe('typegenPrinter: globals', () => {

return content.replace("'nexus'", `'../../src'`)
},
})) as core.NexusGraphQLSchema
})

metadata = new TypegenMetadata({
outputs,
Expand Down

0 comments on commit 92f20dc

Please sign in to comment.