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

Always forward @include & @skip directive with variable reference to downstream #169

Open
bhavinshah7 opened this issue Oct 2, 2023 · 2 comments
Assignees

Comments

@bhavinshah7
Copy link
Contributor

bhavinshah7 commented Oct 2, 2023

The core GraphQL specification includes the following directives:

  • @include(if: Boolean) Only include this field in the result if the argument is true.
  • @skip(if: Boolean) Skip this field if the argument is true.

More info about graphql directives in general here.

In graphql-orchestrator-java, we want these directives to be always included in the downstream query.

Problem

The @include and @Skip are not passed to downstream for the following scenarios:

Directive Current Behavior Expected
@include(if: $var) if var = false, directive is not included in the downstream query. include in downstream query
@Skip(if: $var) if var = true, directive is not included in the downstream query. include in downstream query

Why:

The directives are not added to the list that needs to be included in the downstream query. (see Code). This is because the QueryTraverser.java used in VariableDefinitionFilter.java evaluates the arguments and ignores accordingly. (The QueryTraverser.java JavaDoc explains this as well)

Solution:

We did not find a way to change the behavior of QueryTraverser.java. As an alternative, implement a NodeVisitor and use in VariableDefinitionFilter.java. See an example implementation here.

@kulkarnianiket
Copy link

Hey @bhavinshah7 , I would like to work on this. Thanks

@CNAChino
Copy link
Contributor

@kulkarnianiket assigned the story to you. Feel free to reach out if you need help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants