Skip to content

Inconsistent behaviour of @include directive when used with fragments #5970

Closed

Description

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

This issue relates to v13, it does not occur in v12.

The following query works as expected.

query AppQuery {
  ...AppFragment1_query @include (if: true)
  ...AppFragment2_query @include (if: false)
}

fragment AppFragment1_query on Query {
  environment {
    name
  }
}

fragment AppFragment2_query on Query {
  environment {
    name
  }
}

by giving this result

{
  "data": {
    "environment": {
      "name": "Dev"
    }
  }
}

However, if i rearrange the same query by hoisting up one of the fragments like so...

query AppQuery {
  environment {
    name
  }
  ...AppFragment1_query @include(if: false)
}

fragment AppFragment1_query on Query {
  environment {
    name
  }
}

I now get the incorrect / unexpected result of

{
  "data": {}
}

This is a contrived example but in the real query I use in my app (utilising Relay as a client) it causes an issue once the data is spread out amongst the components.

Steps to reproduce

  1. Use the failing example above (2nd query above) to create a query against any schema

Relevant log output

No response

Additional Context?

No response

Version

13.0.5

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

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions