kevin cline
kevin cline

Reputation: 2736

GraphQL type containing a finite set of string values

In typescript I can write:

type T = 'some words' | 'some other words' | ...

Is it possible to define such a type in GraphQL schema?

I have a downstream service that returns a set of values, some containing blanks and I would like to have a type restricted to only those values.

Upvotes: 1

Views: 602

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20227

You can define a custom scalar that only allows your set of values.

In the absence of spaces you could also use an enum.

Upvotes: 1

Related Questions