nicolasdao / schemaglue

Naturally breaks down your monolithic graphql schema into bits and pieces and then glue them back together.
BSD 3-Clause "New" or "Revised" License
116 stars 13 forks source link

Support for JS definition? #20

Closed timscott closed 4 years ago

timscott commented 4 years ago

I would like to take advantage of graphql-js ability to map integer values to enums be defining it in JS using GraphQLEnumType. Is this possible when using schemaglue?

timscott commented 4 years ago

I figured it out. Leaving here for posterity.

# MyEnum.graphql
enum MyEnum {
  A
  B
  C
}
// resolver.js
export const resolver = {
  MyEnum: {
    A: 1,
    B: 2
    C: 3
  }
};

Now if you resolve a field of type MyEnum with an integer value (e.g. 2) it will resolve to the enum (e.g. B).