How to use the graphql-compose/lib/graphql.GraphQLObjectType 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 / pageInfoType.js View on Github external
/* @flow */

import {
  GraphQLBoolean,
  GraphQLString,
  GraphQLObjectType,
  GraphQLNonNull,
} from 'graphql-compose/lib/graphql';

const PageInfoType = new GraphQLObjectType({
  name: 'PageInfo',
  description: 'Information about pagination in a connection.',
  fields: () => ({
    hasNextPage: {
      type: new GraphQLNonNull(GraphQLBoolean),
      description: 'When paginating forwards, are there more items?',
    },
    hasPreviousPage: {
      type: new GraphQLNonNull(GraphQLBoolean),
      description: 'When paginating backwards, are there more items?',
    },
    startCursor: {
      type: GraphQLString,
      description: 'When paginating backwards, the cursor to continue.',
    },
    endCursor: {
github graphql-compose / graphql-compose-connection / src / __mocks__ / userTC.js View on Github external
/* @flow */
/* eslint-disable no-param-reassign */

import { schemaComposer } from 'graphql-compose';
import {
  GraphQLString,
  GraphQLObjectType,
  GraphQLInputObjectType,
  GraphQLEnumType,
  GraphQLInt,
} from 'graphql-compose/lib/graphql';
import type { ConnectionSortMapOpts } from '../connectionResolver';

export const UserType = new GraphQLObjectType({
  name: 'User',
  fields: {
    id: {
      type: GraphQLInt,
    },
    name: {
      type: GraphQLString,
    },
    age: {
      type: GraphQLInt,
    },
    gender: {
      type: GraphQLString,
    },
  },
});
github graphql-compose / graphql-compose-relay / src / __mocks__ / userTC.js View on Github external
/* @flow */

import { schemaComposer } from 'graphql-compose';
import {
  GraphQLString,
  GraphQLObjectType,
  GraphQLInputObjectType,
  GraphQLNonNull,
  GraphQLInt,
} from 'graphql-compose/lib/graphql';

export const UserType = new GraphQLObjectType({
  name: 'User',
  fields: {
    id: {
      type: GraphQLInt,
    },
    name: {
      type: GraphQLString,
    },
    nickname: {
      type: GraphQLString,
    },
  },
});

export const userTC = schemaComposer.createObjectTC(UserType);
userTC.setRecordIdFn(obj => obj.id);
github graphql-compose / graphql-compose-pagination / src / types / paginationInfoType.js View on Github external
/* @flow */

import {
  GraphQLBoolean,
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLInt,
} from 'graphql-compose/lib/graphql';

const PaginationInfoType = new GraphQLObjectType({
  name: 'PaginationInfo',
  description: 'Information about pagination.',
  fields: () => ({
    currentPage: {
      type: new GraphQLNonNull(GraphQLInt),
      description: 'Current page number',
    },
    perPage: {
      type: new GraphQLNonNull(GraphQLInt),
      description: 'Number of items per page',
    },
    pageCount: {
      type: GraphQLInt,
      description: 'Total number of pages',
    },
    itemCount: {
github graphql-compose / graphql-compose-pagination / src / types / paginationType.js View on Github external
export default function preparePaginationType(typeComposer: TypeComposer): GraphQLObjectType {
  const name = `${typeComposer.getTypeName()}Pagination`;
  const type = typeComposer.getType();

  if (cachedPaginationTypes.has(type)) {
    return (cachedPaginationTypes.get(type): any);
  }

  const paginationType = new GraphQLObjectType({
    name,
    description: 'List of items with pagination.',
    fields: () => ({
      count: {
        type: GraphQLInt,
        description: 'Total object count.',
      },
      items: {
        type: new GraphQLList(typeComposer.getType()),
        description: 'Array of objects.',
      },
      pageInfo: {
        type: new GraphQLNonNull(PaginationInfoType),
        description: 'Information to aid in pagination.',
      },
    }),
github graphql-compose / graphql-compose-relay / src / __mocks__ / userTC.js View on Github external
type: GraphQLInt,
    },
  },
  resolve: resolveParams => {
    return Promise.resolve({
      recordId: resolveParams.args.input.id,
      record: (resolveParams.args && resolveParams.args.input) || {},
    });
  },
});
userTC.setResolver('manyArgsWithInput', manyArgsWithInputResolver);

export const manyArgsWithoutInputResolver = schemaComposer.createResolver({
  name: 'manyArgsWithoutInput',
  kind: 'mutation',
  type: new GraphQLObjectType({
    name: 'UserPayload',
    fields: {
      record: {
        type: UserType,
      },
    },
  }),
  args: {
    sort: {
      name: 'sort',
      type: GraphQLString,
    },
    limit: {
      name: 'limit',
      type: GraphQLInt,
    },