How to use the graphql-compose.NonNullComposer function in graphql-compose

To help you get started, we’ve selected a few graphql-compose 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 graphql-compose / graphql-compose-connection / src / types / connectionType.js View on Github external
const connectionType = typeComposer.schemaComposer.createObjectTC({
    name,
    description: 'A connection to a list of items.',
    fields: {
      count: {
        type: 'Int!',
        description: 'Total object count.',
      },
      pageInfo: {
        type: new NonNullComposer(preparePageInfoType(typeComposer.schemaComposer)),
        description: 'Information to aid in pagination.',
      },
      edges: {
        type: new NonNullComposer(
          new ListComposer(new NonNullComposer(prepareEdgeType(typeComposer)))
        ),
        description: 'Information to aid in pagination.',
      },
    },
  });

  return connectionType;
}
github graphql-compose / graphql-compose-connection / src / types / connectionType.js View on Github external
export function prepareEdgeType(
  typeComposer: ObjectTypeComposer
): ObjectTypeComposer {
  const name = `${typeComposer.getTypeName()}Edge`;

  if (typeComposer.schemaComposer.has(name)) {
    return typeComposer.schemaComposer.getOTC(name);
  }

  const edgeType = typeComposer.schemaComposer.createObjectTC({
    name,
    description: 'An edge in a connection.',
    fields: {
      node: {
        type: new NonNullComposer(typeComposer),
        description: 'The item at the end of the edge',
      },
      cursor: {
        type: 'String!',
        description: 'A cursor for use in pagination',
      },
    },
  });

  return edgeType;
}
github graphql-compose / graphql-compose-connection / src / types / connectionType.js View on Github external
}

  const connectionType = typeComposer.schemaComposer.createObjectTC({
    name,
    description: 'A connection to a list of items.',
    fields: {
      count: {
        type: 'Int!',
        description: 'Total object count.',
      },
      pageInfo: {
        type: new NonNullComposer(preparePageInfoType(typeComposer.schemaComposer)),
        description: 'Information to aid in pagination.',
      },
      edges: {
        type: new NonNullComposer(
          new ListComposer(new NonNullComposer(prepareEdgeType(typeComposer)))
        ),
        description: 'Information to aid in pagination.',
      },
    },
  });

  return connectionType;
}
github graphql-compose / graphql-compose-connection / src / types / connectionType.js View on Github external
const name = `${typeComposer.getTypeName()}${upperFirst(resolverName || 'connection')}`;

  if (typeComposer.schemaComposer.has(name)) {
    return typeComposer.schemaComposer.getOTC(name);
  }

  const connectionType = typeComposer.schemaComposer.createObjectTC({
    name,
    description: 'A connection to a list of items.',
    fields: {
      count: {
        type: 'Int!',
        description: 'Total object count.',
      },
      pageInfo: {
        type: new NonNullComposer(preparePageInfoType(typeComposer.schemaComposer)),
        description: 'Information to aid in pagination.',
      },
      edges: {
        type: new NonNullComposer(
          new ListComposer(new NonNullComposer(prepareEdgeType(typeComposer)))
        ),
        description: 'Information to aid in pagination.',
      },
    },
  });

  return connectionType;
}