How to use the graphi.graphql.GraphQLEnumType function in graphi

To help you get started, we’ve selected a few graphi examples, based on popular ways it is used in public projects.

github joyent / cloudapi-gql / lib / utils.js View on Github external
const type = astSchema.getType(resolverName);
    Assert(type || resolverName === '__schema', `Missing schema definition for resolver: ${resolverName}`);

    const typeResolver = resolvers[resolverName];

    // go through field resolvers for the parent resolver type
    for (const fieldName of Object.keys(typeResolver)) {
      const fieldResolver = typeResolver[fieldName];
      Assert(typeof fieldResolver === 'function', `${resolverName}.${fieldName} resolver must be a function`);

      if (type instanceof graphql.GraphQLScalarType) {
        type[fieldName] = fieldResolver;

      if (type instanceof graphql.GraphQLEnumType) {
        const fieldType = type.getValue(fieldName);
        Assert(fieldType, `${resolverName}.${fieldName} enum definition missing from schema`);
        fieldType.value = fieldResolver;

      // no need to set resolvers unless we are dealing with a type that needs resolvers
      if (!(type instanceof graphql.GraphQLObjectType) && !(type instanceof graphql.GraphQLInterfaceType)) {

      const fields = type.getFields();
      if (!fields) {