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

advise against using schema wrapping #4278

Open
n1ru4l opened this issue Mar 2, 2022 · 2 comments
Open

advise against using schema wrapping #4278

n1ru4l opened this issue Mar 2, 2022 · 2 comments
Labels
docs Focuses on documentation changes

Comments

@n1ru4l
Copy link
Collaborator

n1ru4l commented Mar 2, 2022

wrapSchema usually results in bad performance as it generates a proxy schema.

From looking at https://www.graphql-tools.com/docs/schema-wrapping it is unclear to me which use-cases I might wanna use wrapSchema and what I should prefer to use instead?

The page should start with an disclaimer and guidance on what to use, preferably with real-world examples.
E.g. For use-case X use wrapSchema, otherwise use Y.

@n1ru4l n1ru4l added the docs Focuses on documentation changes label Mar 2, 2022
@klippx
Copy link
Contributor

klippx commented Mar 10, 2022

Interested in this, but what do you mean "advise against"? People who come to wrapSchema are in the need to wrap a remote schema. The performance of it is not a consideration.

But the question we have is - what do we use? I agree this can be a bit unclear, but for me this helped:

Note that schema stitching is a superset of the wrapping API. If you want to combine multiple services (with optional transforms) into one combined gateway schema, then you should use the stitchSchemas method directly and allow it to handle all of the subservice wrappings.

We started with wrapSchema while we had only a single remote schema to wrap, and then switched to stitchSchemas as soon as we had more schemas to wrap. To me it feels like the use case for wrapSchema simply is when you want a single remote schema wrapped with only the customization limited to what SubschemaConfig offers.

stitchSchemas on the other hand can wrap multiple schemas and has customization options that goes way beyond that of SubschemaConfig.

IMO the docs should be restructured. Today we have:

Schema Wrapping <-- Introduction, starts with a subset of stitching. Feels a bit random that this has its own section outside the superset of stitching.
Schema Merging <-- merging wedged in between
> Schema Stitching
    Combining schemas <-- this is the "real" introduction to schema wrapping imo
    Type merging
    ...

I think that it should be like this:

Schema Merging <-- merging moved outside of the stitching topics
Schema Stitching <-- Introduction, starts with the superset of stitching from "Combining schemas"
> Topics
    Type merging    
    ...
    Schema Wrapping <-- Introduce a simpler subset of stitching API here, under the superset of stitching where it belongs.

@n1ru4l
Copy link
Collaborator Author

n1ru4l commented Mar 10, 2022

People have used wrapSchema (including me :D) where mapSchema is more performant if you simply have a GraphQL schema with resolvers.

I dont wanna say there is no need for wrapSchema at all, we should streamline more whether people should use it for achieving X or not.

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

No branches or pull requests

2 participants