Skip to content

Commit

Permalink
Merge pull request #5806 from artsy/dblandin/schema-error-null-my-col…
Browse files Browse the repository at this point in the history
…lection-artwork-id

fix: avoid schema error when Submission#myCollectionArtworkID is null
  • Loading branch information
nickskalkin committed Jun 20, 2024
2 parents fcf8f4b + 39bb7ea commit 683853d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/lib/stitching/convection/__tests__/stitching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,18 @@ it("resolves the myCollectionArtwork field on Consignment Submission", async ()
})
)
})

it("resolves null for the myCollectionArtwork field on Consignment Submission if myCollectionArtworkID is null", async () => {
const { resolvers } = await getConvectionStitchedSchema()
const { myCollectionArtwork } = resolvers.ConsignmentSubmission
const info = { mergeInfo: { delegateToSchema: jest.fn() } }

const response = myCollectionArtwork.resolve(
{ myCollectionArtworkID: null },
{},
{},
info
)

expect(response).toEqual(null)
})
3 changes: 3 additions & 0 deletions src/lib/stitching/convection/v2/stitching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ export const consignmentStitchingEnvironment = (
fragment: `fragment SubmissionArtwork on ConsignmentSubmission { myCollectionArtworkID }`,
resolve: (parent, _args, context, info) => {
const id = parent.myCollectionArtworkID

if (!id) return null

return info.mergeInfo.delegateToSchema({
schema: localSchema,
operation: "query",
Expand Down

0 comments on commit 683853d

Please sign in to comment.