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

gateway: remove use of internal Apollo Server function from LocalGraphQLDataSource #2007

Conversation

glasser
Copy link
Member

@glasser glasser commented Jul 22, 2022

I'm not exactly sure what the purpose of LocalGraphQLDataSource is,
other than that it's a convenient thing to use in this repository's test
suite. It is exported from @apollo/gateway but does not appear to be
documented.

It currently uses a function stolen from the heart of Apollo Server. We
are working on eliminating the dependency of Gateway on Apollo Server
(apollographql/apollo-server#6719,
apollographql/apollo-server#6057) so this
dependency on something that's not even part of the supported API seems
worth looking into.

enablePluginsForSchemaResolvers does two entirely unrelated things.
One is the thing that its name says: it tweaks the schema so that it's
possible to instrument execution on a per-field basis; this is used to
implement Apollo Server's willResolveField plugin hook.

The other thing it does is entirely undocumented: it enables an obscure
and undocumented __resolveObject feature which we are already planning
to remove in Apollo Server 4.

As mentioned, this class seems to really just be a test helper for this
repository, and in fact, the tests did use __resolveObject until a few
months ago in #1658. So one might guess that the point of this line is
just to enable __resolveObject in tests and that it can be entirely
removed.

And in fact, ff45cb7 shows that there used to be a comment here
saying exactly that!

So this commit removes the use of an undocumented internal function to
enable an even less documented feature inside an undocumented class.
The tests pass, so that seems good.

Perhaps one could object to this as not fully backwards compatible,
because perhaps there are users out there who are using
LocalGraphQLDataSource directly and... expect willResolveField plugins
to work? But that's not really something you can make work without the
rest of Apollo Server anyway. I guess maybe they could actually be
expecting __resolveObject to work? But at that point we're talking
about theoretical people trying to combine two undocumented features
(LocalGraphQLDataSource and __resolveObject). If we discover that
those people exist, we can encourage them to just add this line back
into their own code themselves. Surely, people who enjoy the thrill of
using two undocumented features will be even happier using three
undocumented features!

…hQLDataSource

I'm not exactly sure what the purpose of LocalGraphQLDataSource is,
other than that it's a convenient thing to use in this repository's test
suite. It is exported from `@apollo/gateway` but does not appear to be
documented.

It currently uses a function stolen from the heart of Apollo Server. We
are working on eliminating the dependency of Gateway on Apollo Server
(apollographql/apollo-server#6719,
apollographql/apollo-server#6057) so this
dependency on something that's not even part of the supported API seems
worth looking into.

`enablePluginsForSchemaResolvers` does two entirely unrelated things.
One is the thing that its name says: it tweaks the schema so that it's
possible to instrument execution on a per-field basis; this is used to
implement Apollo Server's `willResolveField` plugin hook.

The other thing it does is entirely undocumented: it enables an obscure
and undocumented `__resolveObject` feature which we are already planning
to remove in Apollo Server 4.

As mentioned, this class seems to really just be a test helper for this
repository, and in fact, the tests did use `__resolveObject` until a few
months ago in #1658. So one might guess that the point of this line is
just to enable `__resolveObject` in tests and that it can be entirely
removed.

And in fact, ff45cb7 shows that there used to be a comment here
saying exactly that!

So this commit removes the use of an undocumented internal function to
enable an even less documented feature. The tests pass, so that seems
good.

Perhaps one could object to this as not fully backwards compatible,
because perhaps there are users out there who are using
LocalGraphQLDataSource directly and... expect willResolveField plugins
to work? But that's not really something you can make work without the
rest of Apollo Server anyway. I guess maybe they could actually be
expecting `__resolveObject` to work? But at that point we're talking
about theoretical people trying to combine two undocumented features
(`LocalGraphQLDataSource` and `__resolveObject`). If we discover that
those people exist, we can encourage them to just add this line back
into their own code themselves. Surely, people who enjoy the thrill of
using two undocumented features will be even happier using three
undocumented features!
@netlify
Copy link

netlify bot commented Jul 22, 2022

Deploy Preview for apollo-federation-docs canceled.

Name Link
🔨 Latest commit 7c25aa2
🔍 Latest deploy log https://app.netlify.com/sites/apollo-federation-docs/deploys/62daf6c4bab4f80007e8bf11

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

@benweatherman benweatherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐐

I'm glad this needed to be removed, just so I could read this excellent description

@glasser glasser merged commit cfc4a52 into main Jul 22, 2022
@glasser glasser deleted the glasser/stop-using-an-undocumented-function-to-enable-an-undocumented-feature-inside-an-undocumented-class branch July 22, 2022 19:49
glasser added a commit that referenced this pull request Jul 22, 2022
…hQLDataSource (#2007)

I'm not exactly sure what the purpose of LocalGraphQLDataSource is,
other than that it's a convenient thing to use in this repository's test
suite. It is exported from `@apollo/gateway` but does not appear to be
documented.

It currently uses a function stolen from the heart of Apollo Server. We
are working on eliminating the dependency of Gateway on Apollo Server
(apollographql/apollo-server#6719,
apollographql/apollo-server#6057) so this
dependency on something that's not even part of the supported API seems
worth looking into.

`enablePluginsForSchemaResolvers` does two entirely unrelated things.
One is the thing that its name says: it tweaks the schema so that it's
possible to instrument execution on a per-field basis; this is used to
implement Apollo Server's `willResolveField` plugin hook.

The other thing it does is entirely undocumented: it enables an obscure
and undocumented `__resolveObject` feature which we are already planning
to remove in Apollo Server 4.

As mentioned, this class seems to really just be a test helper for this
repository, and in fact, the tests did use `__resolveObject` until a few
months ago in #1658. So one might guess that the point of this line is
just to enable `__resolveObject` in tests and that it can be entirely
removed.

And in fact, ff45cb7 shows that there used to be a comment here
saying exactly that!

So this commit removes the use of an undocumented internal function to
enable an even less documented feature inside an undocumented class.
The tests pass, so that seems good.

Perhaps one could object to this as not fully backwards compatible,
because perhaps there are users out there who are using
LocalGraphQLDataSource directly and... expect willResolveField plugins
to work? But that's not really something you can make work without the
rest of Apollo Server anyway. I guess maybe they could actually be
expecting `__resolveObject` to work? But at that point we're talking
about theoretical people trying to combine two undocumented features
(`LocalGraphQLDataSource` and `__resolveObject`). If we discover that
those people exist, we can encourage them to just add this line back
into their own code themselves. Surely, people who enjoy the thrill of
using two undocumented features will be even happier using three
undocumented features!
glasser added a commit that referenced this pull request Jul 22, 2022
…hQLDataSource (#2007) (#2008)

I'm not exactly sure what the purpose of LocalGraphQLDataSource is,
other than that it's a convenient thing to use in this repository's test
suite. It is exported from `@apollo/gateway` but does not appear to be
documented.

It currently uses a function stolen from the heart of Apollo Server. We
are working on eliminating the dependency of Gateway on Apollo Server
(apollographql/apollo-server#6719,
apollographql/apollo-server#6057) so this
dependency on something that's not even part of the supported API seems
worth looking into.

`enablePluginsForSchemaResolvers` does two entirely unrelated things.
One is the thing that its name says: it tweaks the schema so that it's
possible to instrument execution on a per-field basis; this is used to
implement Apollo Server's `willResolveField` plugin hook.

The other thing it does is entirely undocumented: it enables an obscure
and undocumented `__resolveObject` feature which we are already planning
to remove in Apollo Server 4.

As mentioned, this class seems to really just be a test helper for this
repository, and in fact, the tests did use `__resolveObject` until a few
months ago in #1658. So one might guess that the point of this line is
just to enable `__resolveObject` in tests and that it can be entirely
removed.

And in fact, ff45cb7 shows that there used to be a comment here
saying exactly that!

So this commit removes the use of an undocumented internal function to
enable an even less documented feature inside an undocumented class.
The tests pass, so that seems good.

Perhaps one could object to this as not fully backwards compatible,
because perhaps there are users out there who are using
LocalGraphQLDataSource directly and... expect willResolveField plugins
to work? But that's not really something you can make work without the
rest of Apollo Server anyway. I guess maybe they could actually be
expecting `__resolveObject` to work? But at that point we're talking
about theoretical people trying to combine two undocumented features
(`LocalGraphQLDataSource` and `__resolveObject`). If we discover that
those people exist, we can encourage them to just add this line back
into their own code themselves. Surely, people who enjoy the thrill of
using two undocumented features will be even happier using three
undocumented features!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants