I am using graphql-codegen
with typescript-mongodb
plugin to generate database model files from the qraphql schema. And therefore my schema contains custom directive from the typescript-mongodb
like @entity
and @column
. The codegen works fine but then when I load the schema using the graphql-tools
loadSchemaSync
function I get a schema validation error which complains about unknown directives.
Probably the most simple solution would be to add the mongo plugin directive definitions to the schema(which I could not yet get working either). But there is not actually any reason to have those directives in the schema after the graphql-codegen generated the configured files.
So I wonder is there some standard way to remove the mongo-related directives from the schema as some intermediate step before loading the schema files into the executable schema?
Or is there a way to tell the loadSchemaSync function to ignore the "unknown directives" error?
Here the my current code to load the schema files:
import { join } from "path";
import {loadSchemaSync, GraphQLFileLoader} from "graphql-tools"
const schema = loadSchemaSync(join(__dirname, '../src/graphql/schemas/**/*.graphql'), {
loaders: [
new GraphQLFileLoader()
]
})