What's the best way to add @tag directive to generated schema file? #1414
-
Looking for some guidance or an example to add directives to the generated schema file.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See https://typegraphql.com/docs/emit-schema.html#emit-schema-with-custom-directives
import { GraphQLSchema, lexicographicSortSchema } from "graphql";
import { printSchemaWithDirectives } from "@graphql-tools/utils";
import { outputFile } from "type-graphql/dist/helpers/filesystem";
export async function emitSchemaDefinitionWithDirectivesFile(
schemaFilePath: string,
schema: GraphQLSchema,
): Promise<void> {
const schemaFileContent = printSchemaWithDirectives(lexicographicSortSchema(schema));
await outputFile(schemaFilePath, schemaFileContent);
}
const schema = await buildSchema(/*...*/);
await emitSchemaDefinitionWithDirectivesFile("/path/to/folder/schema.gql", schema); |
Beta Was this translation helpful? Give feedback.
See https://typegraphql.com/docs/emit-schema.html#emit-schema-with-custom-directives