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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️