1

Given the following interface, where customFields is just a dictionary dynamically populated by the user...

how can I represent it on a gql schema?

interface CustomThing {
  id: string;

  customFields: {
    [key: string]: unknown;
  }
}

The question is more how can I represent { [key: string]: unknown } in graphql?

Hitmands
  • 13,491
  • 4
  • 34
  • 69

1 Answers1

1

You can define a custom scalar type, often called JSON, and make a field of that type on your GraphQL interface. See this library for an example implementation.

Bergi
  • 630,263
  • 148
  • 957
  • 1,375