Fix missing cursor on rest api (#5841)
## Before  ## After   
This commit is contained in:
@ -41,6 +41,7 @@ export class FindManyQueryFactory {
|
|||||||
startCursor
|
startCursor
|
||||||
endCursor
|
endCursor
|
||||||
}
|
}
|
||||||
|
totalCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -11,6 +11,12 @@ export const cleanGraphQLResponse = (input: any) => {
|
|||||||
output[key] = input[key].edges.map((edge) =>
|
output[key] = input[key].edges.map((edge) =>
|
||||||
cleanGraphQLResponse(edge.node),
|
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])) {
|
} else if (isObject(input[key])) {
|
||||||
output[key] = cleanGraphQLResponse(input[key]);
|
output[key] = cleanGraphQLResponse(input[key]);
|
||||||
} else if (key !== '__typename') {
|
} else if (key !== '__typename') {
|
||||||
|
|||||||
@ -111,7 +111,8 @@ describe('computeParameters', () => {
|
|||||||
expect(computeLastCursorParameters()).toEqual({
|
expect(computeLastCursorParameters()).toEqual({
|
||||||
name: 'last_cursor',
|
name: 'last_cursor',
|
||||||
in: 'query',
|
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,
|
required: false,
|
||||||
schema: {
|
schema: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
|||||||
@ -99,7 +99,8 @@ export const computeLastCursorParameters = (): OpenAPIV3_1.ParameterObject => {
|
|||||||
return {
|
return {
|
||||||
name: 'last_cursor',
|
name: 'last_cursor',
|
||||||
in: 'query',
|
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,
|
required: false,
|
||||||
schema: {
|
schema: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
|||||||
@ -22,6 +22,17 @@ export const getFindManyResponse200 = (
|
|||||||
)} with Relations`,
|
)} 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