Only expose certian Queries/Mutations
Borduhh opened this issue · comments
We are contemplating using SOFA to generate an external REST API from our federated GraphQL API, but we want to be able to choose which queries/mutations we expose via the REST API. Is that possible with SOFA?
Ditto
That seems crucial for any serious production use yes.
Is there a way today to achieve something similar maybe by transforming the schema before feeding it to SOFA?
We're currently doing this with graphql-tools as such:
import { FilterRootFields, PruneSchema, schemaFromExecutor, wrapSchema } from "@graphql-tools/wrap"
const operationWhitelist = [
"someoperation",
]
const schema = wrapSchema({
schema: await schemaFromExecutor(executor),
executor,
transforms: [new FilterRootFields((_operationName, fieldName) => operationWhitelist.includes(fieldName)), new PruneSchema()],
})
To those who try to do this with Apollo federation, I managed to get this to work.
import { FilterRootFields, PruneSchema, wrapSchema } from '@graphql-tools/wrap';
const operationWhitelist = ['createUser', 'updateUser', 'user', 'users'];
const wrappedSchema = wrapSchema({
schema: schema,
transforms: [
new FilterRootFields((_operationName, fieldName) => {
return operationWhitelist.includes(fieldName);
}),
new PruneSchema(),
],
});
Then you pass the wrapped schema to Apollo server as usual
Thanks everyone for commenting here
We are aiming to tackle this soon
Is anyone in this thread willing to go on a call with us, walk us through your current setup and your needs, get a shared Slack channel going with The Guild and test the new versions with us till we get it right?
If yes, simply email me (my email is on my GitHub profile)