dangcuuson / graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions
191 stars 36 forks source link

can this support generating enum with given values? #65

Open tx0c opened 3 years ago

tx0c commented 3 years ago

GraphQL allows enum with allow values in resolvers https://www.apollographql.com/docs/apollo-server/schema/schema/#internal-values-advanced

but this is generating always the enum's literal string value, is there anyway can support given values?

https://blog.logrocket.com/what-you-need-to-know-about-graphql-enums/

to make GraphQL

enum AuthType {
 GOOGLE =  'google-auth',
 GITHUB =  'github-auth',
 OUTLOOK = 'outlook-auth',
}

to generate TypeScript

export const enum AuthType {
 GOOGLE =  'google-auth',
 GITHUB =  'github-auth',
 OUTLOOK = 'outlook-auth',
}
tony commented 2 years ago

@tx0c Did you ever find another project or script of your own that could do this? It'd be very valuable to be able to generate a .ts file with concrete enums.

tony commented 2 years ago

Across the pond in apollo: https://github.com/apollographql/apollo-tooling/pull/1750, https://github.com/apollographql/apollo-tooling/issues/1044