How to use the graphi.graphql.parse 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
exports.makeExecutableSchema = ({ typeDefs, resolvers = {} }) => {
  const parsed = graphql.parse(typeDefs);
  const astSchema = graphql.buildASTSchema(parsed, { commentDescriptions: true });

  for (const resolverName of Object.keys(resolvers)) {
    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;
        continue;
github joyent / cloudapi-gql / test / index.js View on Github external
it('has a resolver for every query and mutation in the schema', async () => {
  const fields = [];
  const parsed = graphql.parse(schema.toString());
  for (const def of parsed.definitions) {
    if (def.kind !== 'ObjectTypeDefinition' || (def.name.value !== 'Query' && def.name.value !== 'Mutation')) {
      continue;
    }

    for (const field of def.fields) {
      fields.push(field.name.value);
    }
  }

  const server = await ServerHelper.getServer();
  const paths = server.table().map((route) => {
    return route.path.substr(1);
  });

  for (const field of fields) {

graphi

hapi graphql plugin

MPL-2.0
Latest version published 11 months ago

Package Health Score

59 / 100
Full package analysis

Similar packages