DEV Community

JavaScript Room
JavaScript Room

Posted on

GraphQL schema - sharing Input and Output types structure

Hey GraphQL experts, I have a question for you: how do you achieve re-use of the schema fields when you need to have the same structure in the Input type and the Output?

Let's examine this code (GraphQL schema):

input myInput {
  field1: String
  field2: String
}

type myOutput {
  field1: String
  field2: String
}
Enter fullscreen mode Exit fullscreen mode

Is there any way to re-use the structure here? I've tried to make use of fragments and extends functionality but nothing worked so far.

Is it possible to achieve that and how would you approach it?

TIA!

Top comments (0)