Skip to content

Commit

Permalink
chore: fix tests post-merge and merge resolvers in .fork
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed Apr 12, 2024
1 parent f51a233 commit 25872f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
40 changes: 21 additions & 19 deletions src/testing/core/__tests__/createTestSchema.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1011,24 +1011,26 @@ describe("schema proxy", () => {
});

describe("schema.reset", () => {
const resetTestSchema = createTestSchema(schemaWithMocks, {
Query: {
viewer: () => ({
book: {
text: "Hello World",
title: "Orlando: A Biography",
const resetTestSchema = createTestSchema(schema, {
resolvers: {
Query: {
viewer: () => ({
book: {
text: "Hello World",
title: "Orlando: A Biography",
},
}),
},
Book: {
__resolveType: (obj) => {
if ("text" in obj) {
return "TextBook";
}
if ("colors" in obj) {
return "ColoringBook";
}
throw new Error("Could not resolve type");
},
}),
},
Book: {
__resolveType: (obj) => {
if ("text" in obj) {
return "TextBook";
}
if ("colors" in obj) {
return "ColoringBook";
}
throw new Error("Could not resolve type");
},
},
});
Expand All @@ -1048,7 +1050,7 @@ describe("schema proxy", () => {
},
});

using _fetch = createSchemaFetch(resetTestSchema);
using _fetch = createSchemaFetch(resetTestSchema).mockGlobal();

const client = new ApolloClient({
cache: new InMemoryCache(),
Expand Down Expand Up @@ -1130,7 +1132,7 @@ describe("schema proxy", () => {

resetTestSchema.reset();

using _fetch = createSchemaFetch(resetTestSchema);
using _fetch = createSchemaFetch(resetTestSchema).mockGlobal();

const client = new ApolloClient({
cache: new InMemoryCache(),
Expand Down
4 changes: 3 additions & 1 deletion src/testing/core/createTestSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ const createTestSchema = (

fork: ({ resolvers: newResolvers } = {}) => {
return createTestSchema(targetSchema, {
resolvers: newResolvers ?? targetResolvers,
// @ts-ignore TODO(fixme): IResolvers type does not play well with our Resolvers
resolvers:
mergeResolvers([targetResolvers, newResolvers]) ?? targetResolvers,
scalars: options.scalars,
});
},
Expand Down

0 comments on commit 25872f6

Please sign in to comment.