Switch ApolloServerBase.schema from private access to protected access.#1610
Merged
Conversation
|
@vincenzo: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
ApolloServerBase.schema from private access to protected access.
Contributor
Author
|
Thanks @martijnwalraven, I appreciate the merge! May I ask if you have an ETA for the next release that will include this? It'll unblock my work :) |
Contributor
|
@vincenzo I just published a new release with this PR included :) |
Contributor
Author
|
@martijnwalraven I can only see a new release for |
Contributor
Author
|
Forget that, they were all released 17 hours ago, but they have different versions, so I got confused :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I am proposing this change after a scenario I came across. I essentially wanted to build my class that extends
ApolloServer, and mimic the built-in support for graphql-middleware that graphql-yoga implements.My first implementation of that was done quickly in pure JS for Node (so, no TS) to explore the concept. In that case, of course, you can access anything in an object, so it was easy to do things like:
However, when I decided I wanted to refine this and make it a package, I switched to TypeScript.
So I had my class extending
ApolloServerand my config extendingConfig.And that's when I found out that I couldn't access
this.schemato apply thegraphql-middlewaresafter invoking the constructor of the superclass.Whilst I could work around that by building an executable schema that I then apply the middlewares to before passing it to the
ApolloServerconstructor, that defeats the whole point of extending the base class, because I will have to duplicate a good portion of code inApolloServerBasearound the setting up of the executable schema.I think it's fine for
schemato be protected, and it will open up more possibilities for the subclasses.TODO: