Inline fragments

GraphQL's permits polymorphismarrow-up-right through inline fragmentsarrow-up-right, through objects being available as GraphQL Unionsarrow-up-right and Interfacesarrow-up-right. Eduflow uses inline fragments across the various activity object types.

Eduflow activities all have Activity.title, so all activities inherit from ActivityInterface.

Querying

{
  course(id: "00000000-5945-95c7-65fc-a9747b200320") {
    flows {
      activities {
        ... on ActivityInterface {
          title
        }
      }
    }
  }
}

Inline fragments

Using specific activity fragments act as a way to upcast arrow-up-rightobjects. Here's an example of PeerReview ran against the connection above, and via direct activity lookup.

{
  course(id: "00000000-5945-95c6-65fc-a9747b200320") {
    flows {
      activities {
        __typename
        ... on ActivityInterface {
          title
        }
        ... on PeerReviewActivity {
          reviews {
            edges {
              node {
                reviewType
                createdAt
              }
            }
          }
        }
      }
    }
  }
}

See also

Last updated