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

Unexpected behavior with @include / @skip directives #507

Closed
vladar opened this issue Oct 23, 2015 · 2 comments
Closed

Unexpected behavior with @include / @skip directives #507

vladar opened this issue Oct 23, 2015 · 2 comments

Comments

@vladar
Copy link

vladar commented Oct 23, 2015

I have following fragment:

fragment on Story {
  id
  comments @include(if: $showComments) {
    id
    text
  }
}

Then somewhere in the app I have a list of Stories. When $showComments is true everything works as expected. But when $showComments is false Relay sends additional GraphQL query for each story after initial load.

This query is sent to Node interface and includes this Story fragment (+child fragments if any) as well as id and __typename fields.

The response returned is always the same:

{
  "node": {
    "__typename": "Story",
    "id": "node-id-value"
  }
}

Same applies to @skip(if: true) directive.

@josephsavona
Copy link
Contributor

Relay currently passes through directives to the server but does not directly implement support for @include or @skip. We should add support such that:

  • unincluded fields (include: false or skip: true) are removed during diffing
  • reader does not return unincluded fields

Contributions welcome, otherwise we'll get to this as time permits.

@josephsavona
Copy link
Contributor

merged into #536

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

2 participants