diff --git a/packages/links/tests/upload.test.ts b/packages/links/tests/upload.test.ts index 61da3740d16..9aec2c2070f 100644 --- a/packages/links/tests/upload.test.ts +++ b/packages/links/tests/upload.test.ts @@ -114,7 +114,7 @@ describe('graphql upload', () => { }; const gatewaySchema = stitchSchemas({ - schemas: [subschema], + subschemas: [subschema], resolvers: { Upload: ServerGraphQLUpload, }, diff --git a/packages/merge/tests/merge-typedefs.spec.ts b/packages/merge/tests/merge-typedefs.spec.ts index efb4b9c6f09..42368d5a985 100644 --- a/packages/merge/tests/merge-typedefs.spec.ts +++ b/packages/merge/tests/merge-typedefs.spec.ts @@ -763,7 +763,7 @@ describe('Merge TypeDefs', () => { }); it('should handle extend types when GraphQLSchema is the source', () => { const schema = stitchSchemas({ - schemas: [ + typeDefs: [ ` type Query { foo: String @@ -807,7 +807,7 @@ describe('Merge TypeDefs', () => { it('should handle extend input types', () => { const schema = stitchSchemas({ - schemas: [ + typeDefs: [ ` type Query { foo(i: TestInput): String diff --git a/packages/stitch/src/stitchSchemas.ts b/packages/stitch/src/stitchSchemas.ts index c1bdb298514..3bf2ddb1f3c 100644 --- a/packages/stitch/src/stitchSchemas.ts +++ b/packages/stitch/src/stitchSchemas.ts @@ -5,7 +5,6 @@ import { GraphQLDirective, specifiedDirectives, extendSchema, - isSchema, ASTNode, GraphQLNamedType, } from 'graphql'; @@ -34,8 +33,6 @@ export function stitchSchemas({ subschemas = [], types = [], typeDefs, - // `schemas` to be removed in v7, replaces by subschemas, types, typeDefs - schemas = [], onTypeConflict, mergeDirectives, mergeTypes = false, @@ -77,48 +74,14 @@ export function stitchSchemas({ } }); - // to be removed in v7 - schemas.forEach(schemaLikeObject => { - if ( - !isSchema(schemaLikeObject) && - !isSubschemaConfig(schemaLikeObject) && - typeof schemaLikeObject !== 'string' && - !isDocumentNode(schemaLikeObject) && - !Array.isArray(schemaLikeObject) - ) { - throw new Error('Invalid schema passed'); - } - }); - - // to be removed in v7 - schemas.forEach(schemaLikeObject => { - if (isSchema(schemaLikeObject) || isSubschemaConfig(schemaLikeObject)) { - schemaLikeObjects.push(schemaLikeObject); - } - }); - if ((typeDefs && !Array.isArray(typeDefs)) || (Array.isArray(typeDefs) && typeDefs.length)) { schemaLikeObjects.push(buildDocumentFromTypeDefinitions(typeDefs, parseOptions)); } - // to be removed in v7 - schemas.forEach(schemaLikeObject => { - if (typeof schemaLikeObject === 'string' || isDocumentNode(schemaLikeObject)) { - schemaLikeObjects.push(buildDocumentFromTypeDefinitions(schemaLikeObject, parseOptions)); - } - }); - if (types != null) { schemaLikeObjects = schemaLikeObjects.concat(types); } - // to be removed in v7 - schemas.forEach(schemaLikeObject => { - if (Array.isArray(schemaLikeObject)) { - schemaLikeObjects = schemaLikeObjects.concat(schemaLikeObject); - } - }); - const transformedSchemas: Map = new Map(); const extensions: Array = []; const directives: Array = []; diff --git a/packages/stitch/src/types.ts b/packages/stitch/src/types.ts index 45978d51136..b547aafc703 100644 --- a/packages/stitch/src/types.ts +++ b/packages/stitch/src/types.ts @@ -64,7 +64,6 @@ export interface IStitchSchemasOptions extends Omit>; typeDefs?: ITypeDefinitions; types?: Array; - schemas?: Array; onTypeConflict?: OnTypeConflict; mergeDirectives?: boolean; mergeTypes?: boolean | Array | MergeTypeFilter; diff --git a/packages/stitch/tests/alternateStitchSchemas.test.ts b/packages/stitch/tests/alternateStitchSchemas.test.ts index 92f8fe9ddf2..93717f9307c 100644 --- a/packages/stitch/tests/alternateStitchSchemas.test.ts +++ b/packages/stitch/tests/alternateStitchSchemas.test.ts @@ -426,7 +426,7 @@ describe('optional arguments', () => { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); it('work with schema stitching', async () => { @@ -1494,12 +1494,12 @@ describe('interface resolver inheritance', () => { test('copies resolvers from interface', async () => { const stitchedSchema = stitchSchemas({ - schemas: [ - // pull in an executable schema just so mergeSchema doesn't complain + subschemas: [ + // pull in an executable schema just so stitchSchemas doesn't complain // about not finding default types (e.g. ID) propertySchema, - testSchemaWithInterfaceResolvers, ], + typeDefs: testSchemaWithInterfaceResolvers, resolvers, inheritResolversFromInterfaces: true, }); @@ -1517,12 +1517,12 @@ describe('interface resolver inheritance', () => { test('does not copy resolvers from interface when flag is false', async () => { const stitchedSchema = stitchSchemas({ - schemas: [ + subschemas: [ // pull in an executable schema just so mergeSchema doesn't complain // about not finding default types (e.g. ID) propertySchema, - testSchemaWithInterfaceResolvers, ], + typeDefs: testSchemaWithInterfaceResolvers, resolvers, inheritResolversFromInterfaces: false, }); @@ -1537,12 +1537,12 @@ describe('interface resolver inheritance', () => { test('does not copy resolvers from interface when flag is not provided', async () => { const stitchedSchema = stitchSchemas({ - schemas: [ - // pull in an executable schema just so mergeSchema doesn't complain + subschemas: [ + // pull in an executable schema just so stitchSchemas doesn't complain // about not finding default types (e.g. ID) propertySchema, - testSchemaWithInterfaceResolvers, ], + typeDefs: testSchemaWithInterfaceResolvers, resolvers, }); const query = '{ user { id name } }'; @@ -1573,7 +1573,7 @@ describe('stitchSchemas', () => { }, }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ test { field } }'; @@ -1599,7 +1599,7 @@ describe('stitchSchemas', () => { }, }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ getInput(input: {}) }'; @@ -1645,7 +1645,7 @@ type Query { }, }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], resolvers: { TestScalar: new GraphQLScalarType({ name: 'TestScalar', @@ -1685,7 +1685,7 @@ type Query { }, }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], resolvers: { TestScalar: new GraphQLScalarType({ name: 'TestScalar', @@ -1720,14 +1720,12 @@ type Query { }, }); const stitchedSchema = stitchSchemas({ - schemas: [ - schema, - ` - type Query { - get2: WrappingType - } - `, - ], + subschemas: [schema], + typeDefs: ` + type Query { + get2: WrappingType + } + `, resolvers: { Query: { get2: (_root, _args, context, info) => @@ -1766,7 +1764,7 @@ type Query { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], resolvers: { Query: { wrappingObject: () => ({ @@ -1838,7 +1836,7 @@ describe('onTypeConflict', () => { test('by default takes last type', async () => { const stitchedSchema = stitchSchemas({ - schemas: [schema1, schema2], + subschemas: [schema1, schema2], }); const result1 = await graphql(stitchedSchema, '{ test2 { fieldC } }'); expect(result1.data?.test2.fieldC).toBe('C'); @@ -1848,7 +1846,7 @@ describe('onTypeConflict', () => { test('can use onTypeConflict to select last type', async () => { const stitchedSchema = stitchSchemas({ - schemas: [schema1, schema2], + subschemas: [schema1, schema2], onTypeConflict: (_left, right) => right, }); const result1 = await graphql(stitchedSchema, '{ test2 { fieldC } }'); @@ -1859,7 +1857,7 @@ describe('onTypeConflict', () => { test('can use onTypeConflict to select first type', async () => { const stitchedSchema = stitchSchemas({ - schemas: [schema1, schema2], + subschemas: [schema1, schema2], onTypeConflict: (left) => left, }); const result1 = await graphql(stitchedSchema, '{ test1 { fieldB } }'); diff --git a/packages/stitch/tests/dataloader.test.ts b/packages/stitch/tests/dataloader.test.ts index 6dd53535503..f7692b3dbbe 100644 --- a/packages/stitch/tests/dataloader.test.ts +++ b/packages/stitch/tests/dataloader.test.ts @@ -49,7 +49,7 @@ describe('dataloader', () => { }); const schema = stitchSchemas({ - schemas: [taskSchema, userSchema], + subschemas: [taskSchema, userSchema], typeDefs: ` extend type Task { user: User! diff --git a/packages/stitch/tests/errors.test.ts b/packages/stitch/tests/errors.test.ts index 2154a74dfee..498c979bd90 100644 --- a/packages/stitch/tests/errors.test.ts +++ b/packages/stitch/tests/errors.test.ts @@ -31,7 +31,7 @@ describe('passes along errors for missing fields on list', () => { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ getOuter { innerList { mandatoryField } } }'; @@ -66,7 +66,7 @@ describe('passes along errors for missing fields on list', () => { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ getOuter { innerList { mandatoryField } } }'; @@ -103,7 +103,7 @@ describe('passes along errors when list field errors', () => { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ getOuter { innerList { mandatoryField } } }'; @@ -138,7 +138,7 @@ describe('passes along errors when list field errors', () => { }); const stitchedSchema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], }); const query = '{ getOuter { innerList { mandatoryField } } }'; @@ -207,7 +207,7 @@ describe('passes along errors for remote schemas', () => { }) as ExecutionResult; const stitchedSchema = stitchSchemas({ - schemas: [{ + subschemas: [{ schema, executor, }] diff --git a/packages/stitch/tests/fragments.test.ts b/packages/stitch/tests/fragments.test.ts index b2d441e499c..e58e1e066cd 100644 --- a/packages/stitch/tests/fragments.test.ts +++ b/packages/stitch/tests/fragments.test.ts @@ -78,7 +78,8 @@ describe('stitching', () => { let schema: GraphQLSchema; beforeAll(() => { schema = stitchSchemas({ - schemas: [bookingSchema, propertySchema, proxyTypeDefs], + subschemas: [bookingSchema, propertySchema], + typeDefs: proxyTypeDefs, resolvers: proxyResolvers, }); }); diff --git a/packages/stitch/tests/stitchSchemas.test.ts b/packages/stitch/tests/stitchSchemas.test.ts index ba779447772..b63e87ae319 100644 --- a/packages/stitch/tests/stitchSchemas.test.ts +++ b/packages/stitch/tests/stitchSchemas.test.ts @@ -339,16 +339,18 @@ testCombinations.forEach((combination) => { productSchema = await combination.product; stitchedSchema = stitchSchemas({ - schemas: [ + subschemas: [ propertySchema, bookingSchema, productSchema, - interfaceExtensionTest, scalarSchema, enumSchema, + localSubscriptionSchema, + ], + typeDefs: [ linkSchema, + interfaceExtensionTest, loneExtend, - localSubscriptionSchema, codeCoverageTypeDefs, schemaDirectiveTypeDefs, ], @@ -1545,15 +1547,17 @@ bookingById(id: "b1") { }, }; const schema = stitchSchemas({ - schemas: [ + subschemas: [ propertySchema, bookingSchema, productSchema, - scalarTest, enumSchema, + localSubscriptionSchema, + ], + typeDefs: [ + scalarTest, linkSchema, loneExtend, - localSubscriptionSchema, ], resolvers: [ Scalars, @@ -2906,7 +2910,7 @@ fragment BookingFragment on Booking { }; schema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], resolvers, }); @@ -2940,7 +2944,8 @@ fragment BookingFragment on Booking { }; const schema = stitchSchemas({ - schemas: [propertySchema, typeDefs], + subschemas: [propertySchema], + typeDefs, resolvers, }); @@ -2990,7 +2995,7 @@ fragment BookingFragment on Booking { }; const result = await graphql( - stitchSchemas({ schemas: [BookSchema, AuthorSchema], resolvers }), + stitchSchemas({ typeDefs: [BookSchema, AuthorSchema], resolvers }), ` query { book { @@ -3037,7 +3042,7 @@ fragment BookingFragment on Booking { }; schema = stitchSchemas({ - schemas: [schema], + subschemas: [schema], resolvers, typeDefs: [], }); @@ -3077,7 +3082,7 @@ fragment BookingFragment on Booking { movieSchema = addMocksToSchema({ schema: movieSchema }); const stitchedSchema = stitchSchemas({ - schemas: [bookSchema, movieSchema], + subschemas: [bookSchema, movieSchema], typeDefs: ` schema { query: RootQuery diff --git a/packages/stitch/tests/stitchingFromSubschemas.test.ts b/packages/stitch/tests/stitchingFromSubschemas.test.ts index df419c955dc..a5925979dcf 100644 --- a/packages/stitch/tests/stitchingFromSubschemas.test.ts +++ b/packages/stitch/tests/stitchingFromSubschemas.test.ts @@ -39,7 +39,7 @@ const schemas: Record = {}; const getSchema = (name: string) => schemas[name]; let chirpSchema = stitchSchemas({ - schemas: [ + typeDefs: [ chirpTypeDefs, authorTypeDefs, ` @@ -77,7 +77,7 @@ chirpSchema = addMocksToSchema({ }); let authorSchema = stitchSchemas({ - schemas: [ + typeDefs: [ chirpTypeDefs, authorTypeDefs, ` @@ -117,7 +117,7 @@ schemas.chirpSchema = chirpSchema; schemas.authorSchema = authorSchema; const stitchedSchema = stitchSchemas({ - schemas: Object.keys(schemas).map((schemaName) => schemas[schemaName]), + subschemas:Object.keys(schemas).map((schemaName) => schemas[schemaName]), }); describe('merging without specifying fragments', () => { diff --git a/packages/stitch/tests/transforms.test.ts b/packages/stitch/tests/transforms.test.ts index 8e150dae783..c7ba529eba5 100644 --- a/packages/stitch/tests/transforms.test.ts +++ b/packages/stitch/tests/transforms.test.ts @@ -115,14 +115,14 @@ describe('filter fields', () => { assertValidSchema(filteredSchema); const stitchedSchema = stitchSchemas({ - schemas: [ + subschemas: [ filteredSchema, - ` - extend type Property { - location: Location - } - `, ], + typeDefs: ` + extend type Property { + location: Location + } + `, }); assertValidSchema(stitchedSchema);