Skip to content

Are lean queries supported? #140

@SnidelyWhiplash

Description

@SnidelyWhiplash

As I understand it, queries return fully instantiated Mongoose models by default. But you can override this if you just need the raw data, and don't plan on calling any instance methods, etc by using the lean option...

In my (limited) testing, it doesn't seem like that is supported in resolvers here..? I've tried both Model.find({ query }, null, { lean: true }) and Model.find({ query }).lean() but it seems to prevent me from querying relational data. (It's been a while since I tested, I'm only just now circling back to this. I can provide fuller examples/errors if needed).

In the past, on REST projects, I've noticed significant performance impacts when querying for multiple documents without lean, and in my current GraphQL project I'm thinking this may also be the reason for slow query times.

Thanks for any insight!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions