0
페이지 매김에 사용할 레코드의 총 개수를 추가하려고합니다. 지금 당장 나는 totalCount가 떨어져 있도록 연결을 수정하는 데 문제가있는 연결을 볼 수 있습니다.릴레이/GraphQL 연결에 사용자 정의 필드 추가
Books: {
type: BooksConnection.connectionType,
args: { ...connectionArgs, isbn: { type: GraphQLString }, publisher: {type: GraphQLString}},
resolve: (obj, { ...args }, context, { rootValue: objectManager }) =>
{
let user = obj;
let FormatedArgs = MasterFields.FormatPredicate(args);
return objectManager.getListBy('Book', user, FormatedArgs.queryArgs, objectManager.getViewerUserId()).then((arr) =>
{
let result = {};
result.Books = arr;
result.totalCount = arr.length;
;
//Originally i would just pass arr instead of result.
return connectionFromArray(result, FormatedArgs.connArgs);
})
}
},
이 경우 BookConnection에서 연결 개체를 가져올 수 있습니다. 그 값을 필드에 할당 할 수 있기를 원합니다.
export default connectionDefinitions({
name: 'Books',
nodeType: BookType,
connectionFields:() => ({
totalCount: {
type: GraphQLInt,
resolve: (connection) => { console.log(connection); return connection.totalCount; },
description: `A count of the total number of objects in this connection, ignoring pagination.
This allows a client to fetch the first five objects by passing "5" as the
argument to "first", then fetch the total count so it could display "5 of 83",
for example.`
}
})
});
가 어떻게 totalCount
connection
변수의 속성 수 ? How to pass total count to the client in pageInfo