-
Hello, I'm currently upgrading graphql-tools from an older version (v4.0) to the latest version (v10.0), and I'm encountering issues with mergeSchemas. Here's the section of code where the issue arises: return mergeSchemas({
schemas: [executableSchema1, executableSchema2],
resolvers: {},
}); In version 4.0, mergeSchemas properly combined executableSchema1 and executableSchema2, as shown in this screenshot: However, in version 10.0, it appears that the last schema in the array overwrites the others instead of merging. Any guidance that could assist with the upgrade of graphql-tools would be much appreciated. Here is the full code: import fetch from "node-fetch";
import { HttpLink } from "apollo-link-http";
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import {
introspectSchema,
makeRemoteExecutableSchema,
// mergeSchemas, // this version works
} from "graphql-tools"; // graphql-tools ^2.9.7
import { mergeSchemas } from "@graphql-tools/schema"; // graphql-tools ^10.0.0
async function mergedSchema() {
const starwars = "https://swapi-graphql.netlify.app/.netlify/functions/index";
const rickandmorty = "https://rickandmortyapi.com/graphql";
const httpLink1 = new HttpLink({
uri: starwars,
fetch,
});
const httpLink2 = new HttpLink({
uri: rickandmorty,
fetch,
});
const schema1 = await introspectSchema(httpLink1);
const schema2 = await introspectSchema(httpLink2);
const executableSchema1 = makeRemoteExecutableSchema({
schema: schema1,
link: httpLink1,
});
const executableSchema2 = makeRemoteExecutableSchema({
schema: schema2,
link: httpLink2,
});
return mergeSchemas({
// the latest version overwrites the previous one
schemas: [executableSchema1, executableSchema2],
resolvers: {},
});
}
const runServer = async () => {
const server = new ApolloServer({
schema: await mergedSchema(),
typeDefs: {},
});
const { url } = await startStandaloneServer(server, {
listen: { port: 4000 },
});
console.log(`🚀 Server ready at ${url}`);
};
try {
runServer();
} catch (error) {
console.error(error);
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I migrated to the latest version of graphql-tools, but the issue remains unchanged. So I opened an issue with updated code at: #5395 |
Beta Was this translation helpful? Give feedback.
Closing this discussion because there is already an issue you created.