-
|
Hi, I've been migrating an API to pothos and I wanted to know if there is a I'm mostly using If not, could you add / implement? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
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. |
Beta Was this translation helpful? Give feedback.
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:
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.