-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensible Printer #791
Comments
Hi! I suppose the current structure is not very open for customization 😅 Thanks for sharing your use case, that really helps me see what you have in mind. I think this is also part of the conversation about how to make better use of the GraphQL IDL (eg, #727, #789 ). Here's a possibility I can think of:
That way, you could implement a function for that pre-printing step to assign your directive based on the field's configuration, then it would be printed out just like One issue from the IDL discussion is relevant here: by outputting custom directives, are we breaking compatibility with other GraphQL libraries? |
It sounds great to me! And I don't think outputting custom directives in the IDL will interfere with clients? Most use the JSON output, which, even though directives can exist on any node, does not allow them to be introspected, hence the weird handling of deprecation in the JSON introspection response. I feel like there's definitely a bigger conversation to be had about how directives are exposed through introspection. The following query query { __type(name: "__Field") { fields { name } } } Returns {
"data": {
"__type": {
"fields": [
{
"name": "args"
},
{
"name": "deprecationReason"
},
{
"name": "description"
},
{
"name": "isDeprecated"
},
{
"name": "name"
},
{
"name": "type"
}
]
}
}
} At some point, it may be great for the |
There's now a base https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/language/printer.rb |
This looks awesome! Thank you! |
In an attempt to use custom directives for annotation, I made an attempt to extend the IDL printer. I couldn't find a way to do that didn't involve a monkey patch. The module nesting and composition makes it really hard to break into the underlying printers.
In my case, here's what I had to do to expose one more directive on a field definition:
Would it be possible to refactor the printer to make it more extensible?
The text was updated successfully, but these errors were encountered: