skip to Main Content

let’s say I have a resource product with fields like

  • id
  • name
  • description
  • externalSettings

and external settings is JSON field with unknown data, it can be any data set by the merchant, how can I describe it???

type Product {
   id: ID!,
   name: String!,
   description: String!,
   externalSettings ??? 
}

which type should be here, it’s a JSON object but I can’t describe internals as I do not know them, I just want to be able to query that json as whole and that’s it

2

Answers


  1. GraphQL allows to implement a custom scalar. You have to implement it for JSON .

    Most probably I guess someone should already implement it for you depending on which GraphQL library / framework you use.

    For example in the java world , I would simply use graphql-java-extended-scalars

    Login or Signup to reply.
  2. If you’re developing in js then I can recommend the graphql-scalars package. It includes a JSON type along with many others.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search