Skip to content

Support type-refining fragments #154

@tomhoule

Description

@tomhoule

Fragments can be used to select a specific type on an interface/union.

e.g.

type Dog {
  name: String!
  hasFlappyEars: Boolean!
  hasWaggingTail: Boolean!
}

type Cat {
  meows: Boolean!
  mischievous: Boolean!
  favouriteFood: String!
}

union Pet = Dog | Cat

fragment DogAttributes on Dog {
  hasFlappyEars
  hasWaggingTail
}

# We can then query on a Pet field this way:

myPet {
  ...DogAttributes
}

# This is equivalent to:

myPet {
  ...on Dog {
    ...DogAttributes
  }
}

Relevant section of the spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions