Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Aug 31, 2021
1 parent 9a68b90 commit bbe5d60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 4 additions & 8 deletions src/lib/stitching2/kaws/v2/stitching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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",
Expand Down
15 changes: 9 additions & 6 deletions src/lib/stitching2/mergeSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit bbe5d60

Please sign in to comment.