Skip to content

Support for Grafast plan resolvers #2615

Open
@ronkkol

Description

@ronkkol

Is your feature request related to a problem? Please describe.

We have a large graphql-modules application that uses DataLoader to deal with N+1 problems for database requests. As the requests are asynchronous, we still encounter problems with memory usage. Promises still instantiate in an N+1 way, even though they might get resolved with a smaller number of DB requests.

We looked into Grafast which introduces synchronous plan resolvers instead of traditional GraphQL resolvers to address this problem. Unfortunately, graphql-modules' schema builder doesn't seem to support plans in the schema for modules.

Describe the solution you'd like

I'd like interoperability with Grafast plans in schemas built by graphql-modules. Instead of the schema builder handling typeDefs and resolvers, it would be nice to support plans out-of-the-box.

Describe alternatives you've considered

Grafast's team suggested adding plans under the resolvers' extensions in the following way:

  resolvers: {
    Query: {
      user: {
        extensions: {
          grafast: {
            plan(_, { $id }) {
              return object({
                _id: $id,
                username: constant('jhonFromGrafast')
              });
            }
          }
        }
      }
    }

Unfortunately, when modifying a module's resolvers that way, the final schema does not seem to have the extensions.

Additional context

We use graphql-modules currently and hopefully grafast as well in the future as GraphQL envelop plugins.

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