Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
damassi committed Dec 16, 2021
1 parent 9d21a46 commit cd8e25b
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 204 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
"@babel/preset-env": "7.4.5",
"@babel/preset-typescript": "7.3.3",
"@babel/register": "7.4.4",
"@graphql-tools/delegate": "6.0.10",
"@graphql-tools/graphql-file-loader": "^7.0.6",
"@graphql-tools/load": "^7.1.9",
"@graphql-tools/schema": "^8.1.2",
"@graphql-tools/stitch": "^8.2.1",
"@graphql-tools/wrap": "^8.0.13",
"@graphql-tools/delegate": "^8.4.3",
"@graphql-tools/graphql-file-loader": "^7.3.3",
"@graphql-tools/load": "^7.5.0",
"@graphql-tools/schema": "^8.3.1",
"@graphql-tools/stitch": "^8.4.3",
"@graphql-tools/wrap": "^8.3.2",
"@heroku/foreman": "2.0.2",
"@sentry/node": "5.18.1",
"accounting": "0.4.1",
Expand Down
67 changes: 38 additions & 29 deletions src/lib/stitching2/kaws/v2/stitching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const kawsStitchingEnvironmentV2 = (
marketingCollections: {
selectionSet: `{ internalID }`,
resolve: ({ internalID: artistID }, args, context, info) => {
debugger
return delegateToSchema({
schema: kawsSchema,
operation: "query",
Expand All @@ -61,14 +60,16 @@ export const kawsStitchingEnvironmentV2 = (
},
Fair: {
marketingCollections: {
fragment: `
... on Fair {
kawsCollectionSlugs
}
`,
selectionSet: gql`
{
... on Fair {
kawsCollectionSlugs
}
}
`,
resolve: ({ kawsCollectionSlugs: slugs }, args, context, info) => {
if (slugs.length === 0) return []
return info.stitchingInfo.delegateToSchema({
return delegateToSchema({
schema: kawsSchema,
operation: "query",
fieldName: "marketingCollections",
Expand All @@ -85,29 +86,33 @@ export const kawsStitchingEnvironmentV2 = (
},
HomePage: {
marketingCollectionsModule: {
fragment: gql`
selectionSet: gql`
{
... on HomePage {
__typename
}
`,
}
`,
resolve: () => {
return {}
},
},
},
HomePageMarketingCollectionsModule: {
results: {
fragment: gql`
... on HomePageMarketingCollectionsModule {
__typename
selectionSet: gql`
{
... on HomePageMarketingCollectionsModule {
__typename
}
}
`,
resolve: async (_source, _args, context, info) => {
try {
// We hard-code the collections slugs here in MP so that the app
// can display different collections based only on an MP change
// (and not an app deploy).
return await info.mergeInfo.delegateToSchema({
return delegateToSchema({
schema: kawsSchema,
operation: "query",
fieldName: "marketingCollections",
Expand All @@ -132,17 +137,18 @@ export const kawsStitchingEnvironmentV2 = (
},
Viewer: {
marketingCollections: {
fragment: gql`
...on Viewer {
__typename
selectionSet: gql`
{
... on Viewer {
__typename
}
}
`,
resolve: async (_source, args, context, info) => {
return await info.mergeInfo.delegateToSchema({
return delegateToSchema({
schema: kawsSchema,
operation: "query",
fieldName: "marketingCollections",

args,
context,
info,
Expand All @@ -152,16 +158,17 @@ export const kawsStitchingEnvironmentV2 = (
},
MarketingCollection: {
artworksConnection: {
fragment: `
selectionSet: gql`
fragment MarketingCollectionQuery on MarketingCollection {
query {
${Object.keys(filterArtworksArgs).join("\n")}
}
}
`,
resolve: (parent, _args, context, info) => {
resolve: (parent, args, context, info) => {
const query = parent.query
const hasKeyword = Boolean(parent.query.keyword)
// debugger
const hasKeyword = Boolean(args.keyword)

const existingLoader =
context.unauthenticatedLoaders.filterArtworksLoader
Expand All @@ -174,27 +181,29 @@ export const kawsStitchingEnvironmentV2 = (
// TODO: Should this really modify the context in place?
context.unauthenticatedLoaders.filterArtworksLoader = newLoader

return info.mergeInfo.delegateToSchema({
return delegateToSchema({
schema: localSchema,
operation: "query",
fieldName: "artworksConnection",
args: {
...query,
keywordMatchExact: hasKeyword,
..._args,
...args,
},
context,
info,
})
},
},
internalID: {
fragment: `
fragment MarketingCollectionIDQuery on MarketingCollection {
id
}
`,
resolve: ({ id }, _args, _context, _info) => id,
selectionSet: gql`
fragment MarketingCollectionIDQuery on MarketingCollection {
id
}
`,
resolve: ({ id }, _args, _context, _info) => {
return id
},
},
},
},
Expand Down
Loading

0 comments on commit cd8e25b

Please sign in to comment.