-
Notifications
You must be signed in to change notification settings - Fork 533
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
feat: support graphql
v16
#998
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #998 +/- ##
==========================================
- Coverage 96.08% 95.39% -0.69%
==========================================
Files 14 21 +7
Lines 893 1346 +453
Branches 191 278 +87
==========================================
+ Hits 858 1284 +426
- Misses 35 62 +27
|
4a2f382
to
ba537ee
Compare
ba537ee
to
feccd28
Compare
This PR fixes #784. |
Thanks for the PR. I appreciate the clear PR description and commit structure. 👍
Instrumentation users can actually already use any version. Moving it to peer dependency only makes it installed by default on new npm versions.
Do I understand you correctly that tests fail on graphql v16? How does that qualify supporting it in that case or is it still WIP? |
Hi @rauno56 👋. So prior to this PR users could only use versions other than The peer dependency approach, which includes a formal specification of which peer versions are supported, is what's used by the vast majority of
No, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed the fact that we had graphql
listed under the dependencies not only as a devDep. It's not common among the packages here.
}, | ||
"devDependencies": { | ||
"@opentelemetry/api": "1.0.2", | ||
"@opentelemetry/sdk-trace-base": "1.2.0", | ||
"@types/mocha": "8.2.3", | ||
"@types/node": "16.11.21", | ||
"graphql": "^15.5.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not update it among the dev-deps as well to the latest and leave testing on v15 for TAV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great feedback @rauno56. Those changes are now made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rauno56, I finally had some time to get the tests working while using v16 internally. However, since graphql
v16 doesn't appear to support Node.js v8 or Node.js v10, that has meant conditionally disabling a few of the tests. Perhaps, therefore, you might prefer to use the latest 15.x
internally, so that running npm test
locally exercises all tests.
BTW the failing code coverage check appears to be as a result of an as Error
cast I perform, which is weird since casting is only a notional concept, and does not translate to code paths that can be tested.
graphql was move between dependency and devDependency a few times.
As it is part of the autoinstrument metapackage it's a common setup that users have the instrumentation installed even if they don't use graphql. |
Co-authored-by: Rauno Viskus <Rauno56@users.noreply.github.com>
So by using peer dependencies I believe that this PR takes a third approach, which is different from both of the two previously utilised approaches. That is:
To be clear, I'm not suggesting that this is perfect, but it does seem (to me) like the best compromise. @dyladan, as author of #850 do you have any thoughts on whether this is sufficient, or whether there may be a better solution? |
19acc6e
to
75eb836
Compare
typeInfo?: graphqlTypes.TypeInfo, | ||
options?: { maxErrors?: number } | ||
options?: { maxErrors?: number }, | ||
typeInfo?: graphqlTypes.TypeInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
graphql
v16 flips around these two parameters 🤯 . This has no effect at runtime when using v15 Vs v16 because they both pass whatever they receive through, but needs to be changed in the case we want to compile against v16.
@@ -387,7 +387,7 @@ export function wrapFieldResolver<TSource = any, TContext = any, TArgs = any>( | |||
> | |||
>( | |||
() => { | |||
return fieldResolver.call(this, source, args, contextValue, info); | |||
return fieldResolver.call(this, source, args, contextValue, info) as any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The any
used to be baked into the generic return type, whereas it now uses unknown
instead, which is insufficient here.
@@ -976,7 +979,7 @@ describe('graphql', () => { | |||
assert.deepStrictEqual(spans.length, 1); | |||
}); | |||
|
|||
it('should instrument parse with error', () => { | |||
itMaybe('should instrument parse with error', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test doesn't work on Node.js v8 and Node.js v10 when using graphql
v16, so make only run it on more recent versions of Node.js.
75eb836
to
cce6216
Compare
cce6216
to
92be5ed
Compare
ℹ️ If you're using Yarn then you can actually just force it to use
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days. |
I'm not the right person to review this since i don't even know how graphql works but @open-telemetry/javascript-approvers if someone can that would be nice |
@rauno56 i saw you made modification, are you ok with the current state of the PR ? I can review it if you can more eyes so we can merge this |
@dchambers , I removed the maybe-functionality in tests. @vmarchaud, your review would be helpful for sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, @dchambers. Sorry, that it took so long to get merged.
@vmarchaud, nvm about my comment above. I think we can just merge it once CI becomes green.
Which problem is this PR solving?
graphql
library they want to by makinggraphql
a peer dependency.graphql
v16 by introducing an adaptor function to abstract away the API change in v16.Short description of the changes
graphql
can be made a peer dependency. 🟢graphql
v16. 🔴test-all-versions
, but verified as failing locally on my machine.graphql
adaptor function to fix the broken tests. 🟢test-all-versions
on my machine, but this time where all versions pass again.Checklist
npm run test-all-versions
for the edited package(s) on the latest commit if applicable.