DEV Community

JavaScript Room
JavaScript Room

Posted on

2

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)

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay