Skip to content
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

Add missing directive rendering for derrived types #1275

Merged

Conversation

Fluxx
Copy link
Contributor

@Fluxx Fluxx commented Jan 27, 2022

Adds rendering of directives for unions, enums, interfaces, and input objects whose schemas are automatically derived. Doing so required adding directives arguments to the various helper methods in Types, and the extracting the directives out inside the scala 2 and 3 SchemaDerrivation traits to pass in to those new arguments.

I also updated the test schema used in RenderingSpec to add directives to the various parts of the schema that were missing them.

@paulpdaniels
Copy link
Collaborator

I think there is technically one more place that we are missing which is the schema level directive. i.e.

schema @directive {
  query: Query
}

I think we could possibly modify the RootResolver or add them to the GraphQL construction wdyt?

@Fluxx
Copy link
Contributor Author

Fluxx commented Jan 27, 2022

I think we could possibly modify the RootResolver or add them to the GraphQL construction wdyt?

I'd probably say add a directives argument to RootResolver. It'll then have to pass them to the RootSchemaBuilder built in GraphQL.graphql so that they're available to render() so it can add them there.

@ghostdogpr
Copy link
Owner

For schema directives, can't we just pass them to graphQL(...) in the directives parameter?

@Fluxx
Copy link
Contributor Author

Fluxx commented Jan 28, 2022

For schema directives, can't we just pass them to graphQL(...) in the directives parameter?

So per #1270, the directives passed there now rendered in the full schema SDL (as well as being part of the introspection schema as the were previous to that PR). We could also apply those to the schema type itself in the SDL, but I think that's a bit presumptuous and I as a backend author would want a way to control the directives attached to the schema type in the SDL vs just being declared in the schema. The closest place that exists to defining the schema for an author is the RootResolver, at least in my mind.

I'll also say, long-term I would probably argue that we should collect all directives used by all types in the SDL, and render them in the schema automatically (since they are used in the schema) vs using them in the schema + also having to remember to pass them in to Graphql.graphQL() so they show at the top.

@Fluxx
Copy link
Contributor Author

Fluxx commented Jan 28, 2022

Did you mean to merge this?

@ghostdogpr ghostdogpr merged commit 49536fc into ghostdogpr:master Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants