Skip to content

Commit

Permalink
Added a description to the pagination arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
excitement-engineer committed Oct 14, 2017
1 parent 16108e3 commit aa2d21c
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 4 deletions.
120 changes: 120 additions & 0 deletions src/connection/__tests__/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,124 @@ describe('connectionDefinition()', () => {
const result = await graphql(schema, query);
expect(result).to.deep.equal({ data: expected });
});

it('has the correct pagination arguments', async () => {
const query = `{
__type(name: "User") {
fields {
name
args {
name
description
type {
kind
name
}
}
}
}
}`;

const expected = {
__type: {
fields: [
{
args: [],
name: 'name'
},
{
args: [
{
name: 'after',
description:
'Returns the items in the list that come ' +
'after the specified cursor.',
type: {
kind: 'SCALAR',
name: 'String'
}
},
{
name: 'first',
description: 'Returns the first n items from the list.',
type: {
kind: 'SCALAR',
name: 'Int'
}
},
{
name: 'before',
description:
'Returns the items in the list that come ' +
'before the specified cursor.',
type: {
kind: 'SCALAR',
name: 'String'
}
},
{
name: 'last',
description: 'Returns the last n items from the list.',
type: {
kind: 'SCALAR',
name: 'Int'
}
}
],
name: 'friends'
},
{
args: [
{
name: 'after',
description:
'Returns the items in the list that come ' +
'after the specified cursor.',
type: {
kind: 'SCALAR',
name: 'String'
}
},
{
name: 'first',
description: 'Returns the first n items from the list.',
type: {
kind: 'SCALAR',
name: 'Int'
}
}
],
name: 'friendsForward'
},
{
args: [
{
name: 'before',
description:
'Returns the items in the list that come ' +
'before the specified cursor.',
type: {
kind: 'SCALAR',
name: 'String'
}
},
{
name: 'last',
description: 'Returns the last n items from the list.',
type: {
kind: 'SCALAR',
name: 'Int'
}
}
],
name: 'friendsBackward'
}
]
}
};

const result = await graphql(schema, query);
expect(result).to.deep.equal({ data: expected });
});

});
14 changes: 10 additions & 4 deletions src/connection/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ import type {
*/
export const forwardConnectionArgs: GraphQLFieldConfigArgumentMap = {
after: {
type: GraphQLString
type: GraphQLString,
description:
'Returns the items in the list that come after the specified cursor.'
},
first: {
type: GraphQLInt
type: GraphQLInt,
description: 'Returns the first n items from the list.'
},
};

Expand All @@ -43,10 +46,13 @@ export const forwardConnectionArgs: GraphQLFieldConfigArgumentMap = {
*/
export const backwardConnectionArgs: GraphQLFieldConfigArgumentMap = {
before: {
type: GraphQLString
type: GraphQLString,
description:
'Returns the items in the list that come before the specified cursor.'
},
last: {
type: GraphQLInt
type: GraphQLInt,
description: 'Returns the last n items from the list.'
},
};

Expand Down

0 comments on commit aa2d21c

Please sign in to comment.