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

Added GraphQL type config resolve directive #988

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

magnusnordlander
Copy link

@magnusnordlander magnusnordlander commented Feb 15, 2022

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes/no
Documented? no
Fixed tickets
License MIT

We're looking at federating our schemas, and an important piece in making that process smooth is to be able to define our type configuration using the GraphQL Schema syntax. However, we're not very keen on using resolver maps, and would much rather just define our resolvers using directives in the schema. This PR adds support for defining resolvers using a directive.

I'm creating this as a draft PR, because before any merging I would like to discuss this further, specifically the following points:

  • Is defining schema metadata in directives a road you want to go down?
  • What other metadata should we support?
  • How can we ensure that schema metadata doesn't end up in schema introspection queries?

We're willing to put some work into this, so I'm looking forward to a discussion!

Example of how a schema definition using this:

directive @resolve(
    expression: String!
) on FIELD_DEFINITION

# Represents a review for a movie
type Review {
    # The number of stars this review gave, 1-5
    stars: Int! @deprecated
    # Comment about the movie
    commentary: String @resolve(expression:"@=resolver('reviewcommentary')")
}

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

1 participant