0

Here is a simplified snippet out of a GraphQL Schema I work with. There are - an enum, type Contributor and type Review.

enum CONTRIBUTOR_TYPE {
  AUTHOR
  EDITOR
}

type Contributor {
  name: String
  role: CONTRIBUTOR_TYPE
}

type Article {
  text: String
  authors: [Contributor]
}

What I want to describe, is that the "authors" field is not just array of type Contributor, but Contributor with specific job role. In pseudocode it would look like

 authors: [Contributor{type: CONTRIBUTOR_TYPE.AUTHOR}]!

Is there a way to describe this constraint in GraphQL Schema?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Lula-Leus
  • 21
  • 3

1 Answers1

0

You should be able to use schema directives to describe / enforce the constraint. For apollo server check out https://www.apollographql.com/docs/apollo-server/schema/creating-directives/, for graphql-java check out https://www.graphql-java.com/documentation/v15/sdl-directives/, for other server implementations check their corresponding documentation.

Joe
  • 607
  • 6
  • 13