-
Hi, I am having some difficulty migrating my Apollo Gateway to the new Apollo Sever v4. The issue is that in our code we do a filtering of the Schema before creating the Server, but after creating the Gateway. The code in v3 is: const gateway = new ApolloGateway(config);
const { schema, executor } = await gateway.load();
const publicSchema = graphqlSFilter(schema, graphqlFilterMap); <---- this filters out APIs from the public schema
const server = new ApolloServer({
schema: publicSchema,
executor,
...
}); but in the Apollo v4 I was no able to find a configuration where this works. How do I achieve this in v4? I am open to a completely different approach. The main goal is that we have 2 gateways running in parallel: one used by internal apps with all APIs, and one exposed to external public API with limited operations. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I was able to find a solution! (of course after I asked the question here) I am converting the SDL to GraphQLSchema and back again before creating the gateway: import { buildSchema } from "graphql";
import { printSchemaWithDirectives } from "@graphql-tools/utils";
// ...
const fullSchema = buildSchema(supergraphSdl);
const filteredSchema = graphqlSFilter(fullSchema);
const filteredSdl = printSchemaWithDirectives(filteredSchema, {
assumeValid: true,
commentDescriptions: false,
});
const gateway = new ApolloGateway({
supergraphSdl: filteredSdl,
...
}); |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting back with your solution @tiagodj. You're using what we'd consider a custom executor. We do offer a migration path for your use case in the migration guide. |
Beta Was this translation helpful? Give feedback.
I was able to find a solution! (of course after I asked the question here)
I am converting the SDL to GraphQLSchema and back again before creating the gateway: