GraphQL schema - sharing Input and Output types structure
JavaScript Room

JavaScript Room @room_js

About: Blog about web development

Location:
Amsterdam, Netherlands
Joined:
Jul 24, 2018

GraphQL schema - sharing Input and Output types structure

Publish Date: Apr 24 '23
2 0

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!

Comments 0 total

    Add comment