Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird behaviour of paging #1

Open
akaNightmare opened this issue Aug 7, 2017 · 2 comments
Open

Weird behaviour of paging #1

akaNightmare opened this issue Aug 7, 2017 · 2 comments

Comments

@akaNightmare
Copy link

Hello,

import { GQC } from 'graphql-compose';
import composeWithPagination from 'graphql-compose-pagination';
import userTypeComposer from '../modules/user/types';

GQC.rootQuery().addFields({
    userById: userTypeComposer.getResolver('findById'),
    userOne: userTypeComposer.getResolver('findOne'),
    userMany: userTypeComposer.getResolver('findMany'),
    userCount: userTypeComposer.getResolver('count'),
    userPagination: userTypeComposer.getResolver('pagination'),
});

GQC.rootMutation().addFields({
    userCreate: userTypeComposer.getResolver('createOne'),
});

composeWithPagination(userTypeComposer, {
    findResolverName: 'findMany',
    countResolverName: 'userCount',
});

export default GQC.buildSchema();

GraphQL Query

{
  users: userPagination {
    items {
      name
    }
    pageInfo {
      currentPage
      pageCount
      perPage
      itemCount
    }
  }
}

LOG:
[1] Mongoose: users.find({}, { limit: 21, fields: { items: true, pageInfo: true, name: true } })

I think Items and pageInfo are unnecessary in fields object.

@nodkz
Copy link
Member

nodkz commented Aug 8, 2017

The same behavior exists in connection. It's done for better wrapping your resolvers, all top level projections pass down to find method.

I do not have a suitable example at hand right now. But really was problems when I do not pass top level projection when constructing complex relations between types. So for removing this fields needs to improve projection logic when constructing relations.

In future, it may be fixed, but for now it, not such big problem on which I want to spend my time.

@akaNightmare
Copy link
Author

Thanks, let's keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants