Fragments

Reuse fields for the same object type

You can also reuse chunks of your queries with GraphQL fragments:

fragment ReuseableFragment on Course {
  id
  title
  flows {
    title
  }
}

{
  course(id: "00000000-5945-95c7-65fc-a9747b20031d") {
    ...ReuseableFragment
  }
  anotherCourse: course(id: "00000000-5945-95c6-65fc-a9747b200320") {
    ...ReuseableFragment
  }
}

Another thing to point out: anotherCourse is a GraphQL alias. This is a way to make multiple queries to the same field (query.course)

Last updated