Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @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: {
/* @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,
},
},
});
/* @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);
/* @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: {
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.',
},
}),
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,
},