Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
connectionFromArray
✓ import { connectionFromArray } from 'graphql-skip-limit'
✗ const { connectionFromArray } = require('graphql-skip-limit')
This package is ESM-first; CommonJS require might work with some bundlers but is not guaranteed. Use named import for this function.
connectionArgs
✓ import { connectionArgs } from 'graphql-skip-limit'
✗ import connectionArgs from 'graphql-skip-limit'
connectionArgs is a named export, not a default export. Always use named import syntax.
GraphQLConnectionDef
✓ import type { GraphQLConnectionDef } from 'graphql-skip-limit'
✗ import { GraphQLConnectionDef } from 'graphql-skip-limit'
GraphQLConnectionDef is a TypeScript type and should be imported with `import type` to avoid runtime errors. This is only available in TypeScript environments.
Create a GraphQL schema with skip/limit pagination using connectionFromArray and connectionArgs.
import { connectionArgs, connectionFromArray } from 'graphql-skip-limit';
import { GraphQLObjectType, GraphQLSchema, GraphQLList, GraphQLInt } from 'graphql';
const allFiles = [
{ id: '1', name: 'file1' },
{ id: '2', name: 'file2' },
{ id: '3', name: 'file3' },
{ id: '4', name: 'file4' },
{ id: '5', name: 'file5' },
];
const FileType = new GraphQLObjectType({
name: 'File',
fields: {
id: { type: GraphQLInt },
name: { type: GraphQLString },
},
});
const ConnectionType = new GraphQLObjectType({
name: 'FileConnection',
fields: {
edges: { type: new GraphQLList(FileEdgeType) },
totalCount: { type: GraphQLInt },
},
});
const queryType = new GraphQLObjectType({
name: 'Query',
fields: {
allFile: {
type: ConnectionType,
args: connectionArgs,
resolve: (_, { skip, limit }) => connectionFromArray(allFiles, { skip, limit }),
},
},
});
export const schema = new GraphQLSchema({ query: queryType });
Errors
Common errors & fixes
Error: Cannot find module 'graphql-skip-limit'
The package is not installed or is not in node_modules.
fixRun npm install graphql-skip-limit graphql
TypeError: connectionFromArray is not a function
Default import used instead of named import.
fixChange import to: import { connectionFromArray } from 'graphql-skip-limit' GraphQLError: Unknown argument "skip" on field "allFile".
The connectionArgs are not spread into the field arguments.
fixAdd ...connectionArgs to the field's args object.
Error: limit must be a positive number
Limit argument set to 0 or negative.
fixEnsure limit is a positive integer or omit it.
Audit
Dependencies
graphqlrequiredPeer dependency for building GraphQL types and schemas