apollo-ios: Directives (i.e., @include) not working

I have a fragment

fragment QLOffer on Offer {
    id
    type
    name @include(if: $show)
}

that is then queried by

query Offer($offerId: Int, $show: Boolean = false) {
    offer(id: $offerId) {
        ...QLOffer
    }
}

but the name is always returned.

Some of the generated API code is

public struct QlOffer: GraphQLFragment {
  public static let fragmentString =
    "fragment QLOffer on Offer {" +
    "  __typename" +
    "  id" +
    "  type" +
    "  name @include(if: $show)" +
    "}"

  public static let possibleTypes = ["Offer"]

  public static let selections: [GraphQLSelection] = [
    GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
    GraphQLField("id", type: .nonNull(.scalar(GraphQLID.self))),
    GraphQLField("type", type: .nonNull(.scalar(String.self))),
    GraphQLField("name", type: .nonNull(.scalar(String.self))),
  ]

Any suggestions, or is this a confirmed bug currently?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 34 (14 by maintainers)

Most upvoted comments

@plflanagan: I’m in the process of rewriting the way we deal with conditions, so I don’t necessarily need to know more about the current behavior. This should fix all of these issues, I’ll keep you updated!

@fruitcoder close this, cheers