aPureBase / KGraphQL

Pure Kotlin GraphQL implementation
https://kgraphql.io
MIT License
298 stars 58 forks source link

@include and @skip directives should exclude content, but instead it's returning null value (except if the directive is applied to the query) #209

Open tiagonuneslx opened 1 year ago

tiagonuneslx commented 1 year ago

@skip specs:

The @skip built-in directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional exclusion during execution as described by the if argument.

@include specs:

The @include built-in directive may be provided for fields, fragment spreads, and inline fragments, and allows for conditional inclusion during execution as described by the if argument.

The current implementation differs from the specs, as the content affected by these directives is instead being returned as null.

GraphQL query:

{
  hero {
    name @skip(if: true)
  }
}

Response:

{
  "data": {
    "hero": {
      "name": null
    }
  }
}

This works correctly when the directive is applied to the query itself:

GraphQL query:

{
  hero @skip(if: true) {
    name
  }
}

Response:

{
  "data": {}
}