Allow schemaPrinter to be customized / extended.
See original GitHub issueSome libraries are having to copy the schemaPrinter code to do custom stuff to the output, (@apollo/federation, type-graphql). These libraries require outputting type and field level directives since this isn’t supported in this library. Is there any support to do so, or can the schemPrinter just export the other functions so we don’t have to copy every function or, even better, create a SchemaPrinter class so everything can be over-ridden, then printSchema options can set the printer for BC:
type Options = {
commentDescriptions?: boolean,
printer?: SchemaPrinter
};
const defaultPrinter = new SchemaPrinter();
export function printSchema(schema: GraphQLSchema, options?: Options): string {
const printer = options.printer || defaultPrinter;
return printer.print(
schema,
n => !isSpecifiedDirective(n),
isDefinedType,
options,
);
}
export function printIntrospectionSchema(
schema: GraphQLSchema,
options?: Options,
): string {
const printer = options.printer || defaultPrinter;
return printer.print(
schema,
isSpecifiedDirective,
isIntrospectionType,
options,
);
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:12 (3 by maintainers)
Top Results From Across the Web
SchemaPrinter.Options (graphql-java 9.5 API) - javadoc.io
This will allow you to include the graphql 'extended' scalar types that come with graphql-java such as GraphQLBigDecimal or GraphQLBigInteger. SchemaPrinter ...
Read more >leangen/graphql-spqr - Gitter
I'm trying to create a GraphQL Gateway, which will accept these Dtos and ... Expected Schema extend type NotificationDto { recipients: [UserDto] }...
Read more >How to get the generated scheme file .graphqls using SPQR?
Is there a way to generate the scheme file from an existing code with SPQR annotations integrated? To provide some code let's use...
Read more >Class: GraphQL::Schema — GraphQL Ruby API Documentation
Extend this class to define GraphQL enums in your schema. ... You can provide a custom value with the value: keyword. Examples:
Read more >Custom scalars - Apollo GraphQL Docs
To enable this, you can define custom scalar types. Defining a custom scalar. To define a custom scalar, add it to your schema...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

How about we add a config option:
Whenever a definition that can hold directives is encountered, the given function would be called with it and is free to print any directives.
@IvanGoncharov What if
printSchemaonly printed directives that were not visited during schema construction? Using your example:The first snippet would print:
The second would print: