diff --git a/src/index.ts b/src/index.ts index 05e2ec11cf..24adfe86f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -271,8 +271,8 @@ const app = express() try { const schemaV2 = await getSchemaV2() // This order is important for dd-trace to be able to find the nested routes. - app.use("/v2", (req, res, next) => startApp(schemaV2, "/")(req, res, next)) - app.use("/", (req, res, next) => startApp(schemaV1, "/")(req, res, next)) + app.use("/v2", startApp(schemaV2, "/")) + app.use("/", startApp(schemaV1, "/")) } catch (error) { console.log(error) } diff --git a/src/lib/stitching2/kaws/v2/stitching.ts b/src/lib/stitching2/kaws/v2/stitching.ts index c0d2f39e7c..346e0a1bcc 100644 --- a/src/lib/stitching2/kaws/v2/stitching.ts +++ b/src/lib/stitching2/kaws/v2/stitching.ts @@ -5,6 +5,7 @@ import { } from "schema/v2/filterArtworksConnection" import gql from "lib/gql" import { printType } from "lib/stitching/lib/printType" +import { delegateToSchema } from "@graphql-tools/delegate" export const kawsStitchingEnvironmentV2 = ( localSchema: GraphQLSchema, @@ -41,17 +42,12 @@ export const kawsStitchingEnvironmentV2 = ( resolvers: { Artist: { marketingCollections: { - fragment: ` - ... on Artist { - internalID - } - `, + selectionSet: `{ internalID }`, resolve: ({ internalID: artistID }, args, context, info) => { - return info.mergeInfo.delegateToSchema({ + return delegateToSchema({ schema: kawsSchema, operation: "query", fieldName: "marketingCollections", - args: { artistID, ...args, @@ -71,7 +67,7 @@ export const kawsStitchingEnvironmentV2 = ( `, resolve: ({ kawsCollectionSlugs: slugs }, args, context, info) => { if (slugs.length === 0) return [] - return info.mergeInfo.delegateToSchema({ + return info.stitchingInfo.delegateToSchema({ schema: kawsSchema, operation: "query", fieldName: "marketingCollections", diff --git a/src/lib/stitching2/mergeSchemas.ts b/src/lib/stitching2/mergeSchemas.ts index 398d8d3c27..6ebc8dcc93 100644 --- a/src/lib/stitching2/mergeSchemas.ts +++ b/src/lib/stitching2/mergeSchemas.ts @@ -24,18 +24,21 @@ export const incrementalMergeSchemas2 = async (localSchema) => { } const kawsSchema = await executableKawsSchema() - subschemas.push(kawsSchema.schema) - useStitchingEnvironment( - kawsStitchingEnvironmentV2(localSchema, kawsSchema.schema) - ) + subschemas.push(kawsSchema) + useStitchingEnvironment(kawsStitchingEnvironmentV2(localSchema, kawsSchema)) - const stitchedSchemas = stitchSchemas({ + const stitchedSchema = stitchSchemas({ subschemas, resolvers: extensionResolvers, typeDefs: extensionSchemas, }) + // Because __allowedLegacyNames isn't in the public API + Object.defineProperty(stitchedSchema, "__allowedLegacyNames", { + value: ["__id"], + }) + // debugger - return stitchedSchemas + return stitchedSchema }