Skip to content

What's the best way to add @tag directive to generated schema file? #1414

Answered by carlocorradini
jwpark511 asked this question in Q&A
Discussion options

You must be logged in to vote

See https://typegraphql.com/docs/emit-schema.html#emit-schema-with-custom-directives

Currently TypeGraphQL does not directly support emitting the schema with custom directives due to printSchema function limitations from graphql-js.
If we want the custom directives to appear in the generated schema definition file we have to create a custom function that use a third-party printSchema function.
Below there is an example that uses the printSchemaWithDirectives function from @graphql-tools/utils:

import { GraphQLSchema, lexicographicSortSchema } from "graphql";
import { printSchemaWithDirectives } from "@graphql-tools/utils";
import { outputFile } from "type-graphql/dist/helpers/filesystem";

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@carlocorradini
Comment options

@jwpark511
Comment options

Answer selected by jwpark511
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants