Skip to content
Discussion options

You must be logged in to vote

GraphQL doesn't have a way to represent that. You mentioned migrating, what does the existing graphql schema look like?

At the typescript level you can do something like:

builder.objectRef<{ prop: string | string[] }>('Type'). implement({
  fields: (t) => ({
    prop: t.stringList({
      resolve: (parent) => Array.isArray(parent.prop) ? parent.prop : [parent.prop]
  })
})

Your typescript types can be anything you want, but the GraphQL types are limited by what's possible in GraphQL

If your typescript and graphql types are different, you need resolvers to map between them, like in this example we take the string or array of strings and always make it an array on the graphql side.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dougg0k
Comment options

@hayes
Comment options

hayes Apr 5, 2025
Maintainer

Answer selected by dougg0k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants