Skip to content

[Question] Using libraries such as join-monster, which rely on mutating schema instance #198

Closed
@jbroadice

Description

@jbroadice

Hi again.

I've recently discovered a few GraphQL libraries that work by decorating / mutating the schema (GraphQLSchema) instance, and depend on those changes being persisted and not overwritten, such that those decorations can be accessed in resolvers with the resolverInfo argument (fourth argument). For example, join-monster requires adding custom properties to GraphQLObjectType constructors in order to be configured. When using Apollo, this can be achieved using an adapter, such as join-monster-graphql-tools-adapter, which works by decorating / mutating the schema based on a custom object you pass to it.

As far as I can tell, I cannot rely on mutating the schema instance in such a way when using GraphQL Modules, as the schema are built using a factory method, which is called at strategic points in the control flow.

This has lead me to abandon the idea of being able to use such libraries with GraphQL Modules, viewing them as being idiomatically incompatible with one another. Is this an accurate conclusion, or have I missed something? Perhaps the solution could be as simple as formalising an interface for mutating / transforming a schema at a strategic point before the resolvers get called?

Cheers.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions