graphql-rust/graphql-client

Fragments as Traits

eadgbear opened this issue · 1 comments

Let's say I have some fragments:

fragment TeamIdent on Team {
  _id
  name
}

fragment ProjectIdent on Project {
    _id
    name
    team {
        ...TeamIdent
    }
}

And the query:

query ListAll($email: String = "") {
  User(email: $email) {
    _id
    projects {
      ...ProjectIdent
    }
    pipelines {
      name
      _id
      project {
        ...ProjectIdent
      }
    }
}

Would it be at all possible to create traits from those fragments so that I could create re-usable functions around them? Like ListAllUserProjects could implement trait ProjectIdent so that _id and _name were abstracted as functions.

I'm selecting the same fields for a very nested graph definition and I was hoping there was a way I could make it more generic.

Hi @slyons, would you be so kind to show, how to use the trait of a fragment?