Eduflow
  • Welcome
  • API Reference
  • API Explorer
  • Getting started
    • API Overview
    • Authentication
    • Usage
  • GraphQL at Eduflow
    • Introduction to GraphQL
    • Variables
    • Fragments
    • Paginating queries
    • Inline fragments
  • Guides
    • Institutions
    • Courses
    • Flows and Activities
    • Reviews and Reflections
    • Discussions
    • Quizzes
    • Users & Participants
    • Tags
    • Course summary (outputs)
    • vs Peergrade
  • API Changelog
Powered by GitBook
On this page

Was this helpful?

  1. GraphQL at Eduflow

Fragments

Reuse fields for the same object type

PreviousVariablesNextPaginating queries

Last updated 4 years ago

Was this helpful?

You can also reuse chunks of your queries with :

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
  }
}
{
  course(id: "00000000-5945-95c7-65fc-a9747b20031d") {
    id
    title
    flows {
      title
    }
  }
  anotherCourse: course(id: "00000000-5945-95c6-65fc-a9747b200320") {
    id
    title
    flows {
      title
    }
  }
}
{
  "data": {
    "course": {
      "id": "00000000-5945-95c6-65fc-a9747b200317",
      "title": "History 101",
      "flows": [
        {
          "title": "Welcome to History 101"
        },
        {
          "title": "Nascent Civilization"
        }
      ]
    },
    "anotherCourse": {
      "id": "00000000-5945-95c7-65fd-a9747b200320",
      "title": "M & A 101",
      "flows": [
        {
          "title": "Welcome to Mergers & Acquisitions 101"
        },
        {
          "title": "Flow 1 - SEC Regulatory Measures"
        },
        {
          "title": "Flow 2 - Intro"
        },
        {
          "title": "Flow 3 - Mergers"
        },
        {
          "title": "Flow 4 - Acquistions"
        },
        {
          "title": "Mergeable activities"
        }
      ]
    }
  }
}

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

GraphQL fragments
GraphQL alias