Using https://graphql-code-generator.com/, the type in GraphQL is just set to String
, but in my client code with the dropdown input, the type is more specific because it is derived from the dropdown options themselves:
export const CODE_NAME_MAP = {
AFG: 'Afghanistan',
AGO: 'Angola',
// ...
export type Country = typeof CODE_NAME_MAP[keyof typeof CODE_NAME_MAP]
In this case, the graphql data returned from the server has a less specific type than what the client does. Is there a better way to represent these types so they're the same? I got validation errors trying to use the country names in an enum.