Skip to content

Commit

Permalink
chore: Restore integration codegen removed in #629 and #630 (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser authored Nov 21, 2020
1 parent 481e2c7 commit ab4b627
Show file tree
Hide file tree
Showing 16 changed files with 6,078 additions and 19 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module.exports = {
},
},
collectCoverageFrom: ['src/**/*'],
testSequencer: '<rootDir>/tests/__helpers/sequencer.js',
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"release:pr": "dripip pr",
"release:preview": "dripip preview",
"release:stable": "dripip stable",
"test": "yarn test:types && jest integrations && jest --testPathIgnorePatterns integrations docs",
"test:ci": "yarn test:types && jest integrations --coverage && jest --testPathIgnorePatterns integrations docs --coverage",
"test": "yarn test:types && jest",
"test:ci": "yarn test:types && jest --maxWorkers 2 --coverage",
"test:debug": "node --inspect-brk $(yarn bin)/jest -i --watch",
"test:types": "tsc -p tsconfig.spec.types.json",
"ts-ast-reader": "cd examples/ts-ast-reader && yarn start",
Expand Down
16 changes: 16 additions & 0 deletions tests/__helpers/sequencer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// testSequencer.js
const path = require('path')
const Sequencer = require('@jest/test-sequencer').default

class NexusSequencer extends Sequencer {
sort(tests) {
// Test structure information
// https://github.com/facebook/jest/blob/6b8b1404a1d9254e7d5d90a8934087a9c9899dab/packages/jest-runner/src/types.ts#L17-L21
const copyTests = Array.from(tests)
return copyTests.sort((testA, testB) =>
testA.path.includes(path.join('tests', 'integrations')) ? 1 : -1
)
}
}

module.exports = NexusSequencer
12 changes: 1 addition & 11 deletions tests/__helpers/testApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference path="../_setup.ts" />
import { writeFileSync } from 'fs'
import { join, relative } from 'path'
import { core } from '../../src'
import { BuilderConfigInput } from '../../src/core'
Expand Down Expand Up @@ -47,16 +46,7 @@ export async function generateTypegen(settings: HookSettings) {
}

export function installGenerateTypegenHook(settings: HookSettings) {
let typegenPath: string | null = null
beforeAll(async () => {
const { typegenModulePath } = await generateTypegen(settings)

typegenPath = typegenModulePath
})

afterAll(() => {
writeFileSync(typegenPath!, '')
})
beforeAll(() => generateTypegen(settings))
}

type Settings = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/

import { core } from '../../../../src'

declare global {
interface NexusGen extends NexusGenTypes {}
}

export interface NexusGenInputs {}

export interface NexusGenEnums {}

export interface NexusGenScalars {
String: string
Int: number
Float: number
Boolean: boolean
ID: string
}

export interface NexusGenObjects {
A: {
// root type
name?: string | null // String
}
B: {
// root type
age?: number | null // Int
}
Query: {}
}

export interface NexusGenInterfaces {}

export interface NexusGenUnions {
Union: core.Discriminate<'A', 'required'> | core.Discriminate<'B', 'required'>
}

export type NexusGenRootTypes = NexusGenObjects & NexusGenUnions

export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars

export interface NexusGenFieldTypes {
A: {
// field return type
name: string | null // String
}
B: {
// field return type
age: number | null // Int
}
Query: {
// field return type
union: NexusGenRootTypes['Union'] | null // Union
}
}

export interface NexusGenFieldTypeNames {
A: {
// field return type name
name: 'String'
}
B: {
// field return type name
age: 'Int'
}
Query: {
// field return type name
union: 'Union'
}
}

export interface NexusGenArgTypes {}

export interface NexusGenAbstractTypeMembers {
Union: 'A' | 'B'
}

export interface NexusGenTypeInterfaces {}

export type NexusGenObjectNames = keyof NexusGenObjects

export type NexusGenInputNames = never

export type NexusGenEnumNames = never

export type NexusGenInterfaceNames = never

export type NexusGenScalarNames = keyof NexusGenScalars

export type NexusGenUnionNames = keyof NexusGenUnions

export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never

export type NexusGenAbstractsUsingStrategyResolveType = never

export type NexusGenFeaturesConfig = {
abstractTypeStrategies: {
resolveType: true
isTypeOf: true
__typename: true
}
}

export interface NexusGenTypes {
context: any
inputTypes: NexusGenInputs
rootTypes: NexusGenRootTypes
argTypes: NexusGenArgTypes
fieldTypes: NexusGenFieldTypes
fieldTypeNames: NexusGenFieldTypeNames
allTypes: NexusGenAllTypes
typeInterfaces: NexusGenTypeInterfaces
objectNames: NexusGenObjectNames
inputNames: NexusGenInputNames
enumNames: NexusGenEnumNames
interfaceNames: NexusGenInterfaceNames
scalarNames: NexusGenScalarNames
unionNames: NexusGenUnionNames
allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames']
allOutputTypes:
| NexusGenTypes['objectNames']
| NexusGenTypes['enumNames']
| NexusGenTypes['unionNames']
| NexusGenTypes['interfaceNames']
| NexusGenTypes['scalarNames']
allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes']
abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames']
abstractTypeMembers: NexusGenAbstractTypeMembers
objectsUsingAbstractStrategyIsTypeOf: NexusGenObjectsUsingAbstractStrategyIsTypeOf
abstractsUsingStrategyResolveType: NexusGenAbstractsUsingStrategyResolveType
features: NexusGenFeaturesConfig
}

declare global {
interface NexusGenPluginTypeConfig<TypeName extends string> {}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {}
interface NexusGenPluginSchemaConfig {}
interface NexusGenPluginArgConfig {}
}
141 changes: 141 additions & 0 deletions tests/integrations/abstractTypes/isTypeOfsImplemented/__typegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/**
* This file was generated by Nexus Schema
* Do not make changes to this file directly
*/

declare global {
interface NexusGen extends NexusGenTypes {}
}

export interface NexusGenInputs {}

export interface NexusGenEnums {}

export interface NexusGenScalars {
String: string
Int: number
Float: number
Boolean: boolean
ID: string
}

export interface NexusGenObjects {
A: {
// root type
name?: string | null // String
}
B: {
// root type
age?: number | null // Int
}
Query: {}
}

export interface NexusGenInterfaces {}

export interface NexusGenUnions {
Union: NexusGenRootTypes['A'] | NexusGenRootTypes['B']
}

export type NexusGenRootTypes = NexusGenObjects & NexusGenUnions

export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars

export interface NexusGenFieldTypes {
A: {
// field return type
name: string | null // String
}
B: {
// field return type
age: number | null // Int
}
Query: {
// field return type
union: NexusGenRootTypes['Union'] | null // Union
}
}

export interface NexusGenFieldTypeNames {
A: {
// field return type name
name: 'String'
}
B: {
// field return type name
age: 'Int'
}
Query: {
// field return type name
union: 'Union'
}
}

export interface NexusGenArgTypes {}

export interface NexusGenAbstractTypeMembers {
Union: 'A' | 'B'
}

export interface NexusGenTypeInterfaces {}

export type NexusGenObjectNames = keyof NexusGenObjects

export type NexusGenInputNames = never

export type NexusGenEnumNames = never

export type NexusGenInterfaceNames = never

export type NexusGenScalarNames = keyof NexusGenScalars

export type NexusGenUnionNames = keyof NexusGenUnions

export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = 'A' | 'B'

export type NexusGenAbstractsUsingStrategyResolveType = never

export type NexusGenFeaturesConfig = {
abstractTypeStrategies: {
resolveType: true
isTypeOf: true
__typename: false
}
}

export interface NexusGenTypes {
context: any
inputTypes: NexusGenInputs
rootTypes: NexusGenRootTypes
argTypes: NexusGenArgTypes
fieldTypes: NexusGenFieldTypes
fieldTypeNames: NexusGenFieldTypeNames
allTypes: NexusGenAllTypes
typeInterfaces: NexusGenTypeInterfaces
objectNames: NexusGenObjectNames
inputNames: NexusGenInputNames
enumNames: NexusGenEnumNames
interfaceNames: NexusGenInterfaceNames
scalarNames: NexusGenScalarNames
unionNames: NexusGenUnionNames
allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames']
allOutputTypes:
| NexusGenTypes['objectNames']
| NexusGenTypes['enumNames']
| NexusGenTypes['unionNames']
| NexusGenTypes['interfaceNames']
| NexusGenTypes['scalarNames']
allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes']
abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames']
abstractTypeMembers: NexusGenAbstractTypeMembers
objectsUsingAbstractStrategyIsTypeOf: NexusGenObjectsUsingAbstractStrategyIsTypeOf
abstractsUsingStrategyResolveType: NexusGenAbstractsUsingStrategyResolveType
features: NexusGenFeaturesConfig
}

declare global {
interface NexusGenPluginTypeConfig<TypeName extends string> {}
interface NexusGenPluginFieldConfig<TypeName extends string, FieldName extends string> {}
interface NexusGenPluginSchemaConfig {}
interface NexusGenPluginArgConfig {}
}
Loading

0 comments on commit ab4b627

Please sign in to comment.