1

I have to declare in my schema several object models as type and as input.

type Agreement {
    id: Int
    agmtCategCd: String
    agmtSubcategyCd: String
}

input AgreementInput {
    id: Int
    agmtCategCd: String
    agmtSubcategyCd: String
}

As you see the body of AgreementInput and Agreement is exactly the same.

I want to avoid duplicate code. Is there a manner to avoid that ? for example

AgreementInput extends Agreement

or

input AgreementInput  = Agreement
Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
  • 1
    Possible duplicate of [How to Inherit or Extend typeDefs in GraphQL](https://stackoverflow.com/questions/47523384/how-to-inherit-or-extend-typedefs-in-graphql) – Daniel Rearden Apr 24 '18 at 17:07
  • 1
    This question has been asked a number of times before. The bottom line is that GraphQL does not inherently support any kind of type inheritance. There are libraries out there to add that functionality though (see above link). – Daniel Rearden Apr 24 '18 at 17:14
  • Possible duplicate of [How to share common fields btw Input and Type in GraphQL](https://stackoverflow.com/questions/52101396/how-to-share-common-fields-btw-input-and-type-in-graphql) – Dan Dascalescu May 19 '19 at 04:08

0 Answers0