Fix missing cursor on rest api (#5841)
## Before  ## After   
This commit is contained in:
@ -41,6 +41,7 @@ export class FindManyQueryFactory {
|
||||
startCursor
|
||||
endCursor
|
||||
}
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@ -11,6 +11,12 @@ export const cleanGraphQLResponse = (input: any) => {
|
||||
output[key] = input[key].edges.map((edge) =>
|
||||
cleanGraphQLResponse(edge.node),
|
||||
);
|
||||
if (input[key].pageInfo) {
|
||||
output['pageInfo'] = input[key].pageInfo;
|
||||
}
|
||||
if (input[key].totalCount) {
|
||||
output['totalCount'] = input[key].totalCount;
|
||||
}
|
||||
} else if (isObject(input[key])) {
|
||||
output[key] = cleanGraphQLResponse(input[key]);
|
||||
} else if (key !== '__typename') {
|
||||
|
||||
@ -111,7 +111,8 @@ describe('computeParameters', () => {
|
||||
expect(computeLastCursorParameters()).toEqual({
|
||||
name: 'last_cursor',
|
||||
in: 'query',
|
||||
description: 'Returns objects starting from a specific cursor.',
|
||||
description:
|
||||
'Returns objects starting from a specific cursor. You can find cursors in **startCursor** and **endCursor** in **pageInfo** in response data',
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'string',
|
||||
|
||||
@ -99,7 +99,8 @@ export const computeLastCursorParameters = (): OpenAPIV3_1.ParameterObject => {
|
||||
return {
|
||||
name: 'last_cursor',
|
||||
in: 'query',
|
||||
description: 'Returns objects starting from a specific cursor.',
|
||||
description:
|
||||
'Returns objects starting from a specific cursor. You can find cursors in **startCursor** and **endCursor** in **pageInfo** in response data',
|
||||
required: false,
|
||||
schema: {
|
||||
type: 'string',
|
||||
|
||||
@ -22,6 +22,17 @@ export const getFindManyResponse200 = (
|
||||
)} with Relations`,
|
||||
},
|
||||
},
|
||||
pageInfo: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
hasNextPage: { type: 'boolean' },
|
||||
startCursor: { type: 'string' },
|
||||
endCursor: { type: 'string' },
|
||||
},
|
||||
},
|
||||
totalCount: {
|
||||
type: 'integer',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user