How to use the graphile-utils.makeExtendSchemaPlugin function in graphile-utils

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alex-ald / postgraphile-nest / lib / factories / plugin.factory.ts View on Github external
throw new Error('typeName, fieldName, and fieldType are required for ExtendSchema');
    }

    typeName = typeName.trim();
    fieldName = fieldName.trim();

    const matches = fieldName.match(/^\w+/);

    // If no field name exists, then ignore creating the plugin
    if (isNil(matches)) {
      throw new Error('Unable to create ExtendSchema plugin because a field name'
        + ' was not provided or is not in correct form. fieldname: ' + fieldName);
    }

    const fieldNameWithoutParams = matches[0];
    return makeExtendSchemaPlugin(build => {
      return {
        typeDefs: gql`
          ${additionalGraphql}

          extend type ${typeName} {
            ${fieldName}: ${fieldType}
          }
        `,
        resolvers: {
          [typeName]: {
            [fieldNameWithoutParams]: async (query, args, context, resolveInfo) => {
              return await resolver(query, args, context, resolveInfo, build);
            },
          },
        },
      };
github graphile / bootstrap-react-apollo / server / plugins / authentication.js View on Github external
const { makeExtendSchemaPlugin, gql } = require("graphile-utils");

const PassportLoginPlugin = makeExtendSchemaPlugin(build => ({
  typeDefs: gql`
    input RegisterInput {
      username: String!
      email: String!
      password: String!
      name: String
      avatarUrl: String
    }

    type RegisterPayload {
      user: User! @pgField
    }

    input LoginInput {
      username: String!
      password: String!