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

graphql-js 16 support #625

Merged
merged 3 commits into from
Oct 27, 2021
Merged

graphql-js 16 support #625

merged 3 commits into from
Oct 27, 2021

Conversation

n1ru4l
Copy link
Owner

@n1ru4l n1ru4l commented Aug 27, 2021

Run tests for both GraphQL.js 15 and 16 ✅

issues:

Conflicts with Types GraphQL.js 15

subscribe (Now solved ✅ )

subscribe changed return type usages from AsyncIterableIterator to AsyncGenerator. I cast those to AsyncGenerator within the code.

Error: packages/core/src/orchestrator.ts(280,41): error TS2345: Argument of type '(args: SubscriptionArgs) => Promise<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }> | AsyncIterableIterator<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>>' is not assignable to parameter of type '(args: SubscriptionArgs) => PromiseOrValue<AsyncGeneratorOrValue<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>>'.

Error: packages/core/src/orchestrator.ts(347,35): error TS2345: Argument of type 'AsyncIterableIterator<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>' is not assignable to parameter of type 'AsyncGenerator<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>, void, void>'.

Error: packages/core/src/orchestrator.ts(323,9): error TS2322: Type 'ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }> | AsyncIterableIterator<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>' is not assignable to type 'ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }> | AsyncGenerator<ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>, any, unknown>'.

Parser (PR pending 📝 )

GraphQL.js 16 added types for Parser, thus I had to remove the declarations for the v15 Parser definition. This results in v15 build complaining about missing types. We need to find a way to conditionally add definitions for Parser when running v15 builds or ad a lot lot lot of ts-ignore statements.

I figured out the easiest way would be to just have those type-definitions within GraphQL.js 15, so I created a PR over here: graphql/graphql-js#3251

Error: packages/plugins/fragment-arguments/src/extended-parser.ts(2,24): error TS2724: '"graphql/language/parser"' has no exported member named 'Parser'. Did you mean 'parse'?
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(28,10): error TS2339: Property 'expectToken' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(29,35): error TS2339: Property 'expectOptionalKeyword' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(31,35): error TS2339: Property 'peek' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(32,25): error TS2339: Property 'parseFragmentName' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(34,16): error TS2339: Property 'peek' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(38,27): error TS2551: Property 'parseArguments' does not exist on type 'FragmentArgumentCompatibleParser'. Did you mean 'parseFragment'?
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(39,28): error TS2339: Property 'parseDirectives' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(46,20): error TS2339: Property 'parseFragmentName' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(47,26): error TS2339: Property 'parseDirectives' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(54,46): error TS2339: Property 'parseNamedType' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(55,24): error TS2339: Property 'parseDirectives' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(56,26): error TS2339: Property 'parseSelectionSet' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(63,10): error TS2339: Property 'expectKeyword' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(64,23): error TS2339: Property 'parseFragmentName' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(66,14): error TS2339: Property 'peek' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(70,35): error TS2339: Property 'parseVariableDefinitions' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(71,30): error TS2339: Property 'expectKeyword' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(71,56): error TS2339: Property 'parseNamedType' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(72,26): error TS2339: Property 'parseDirectives' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(73,28): error TS2339: Property 'parseSelectionSet' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(81,28): error TS2339: Property 'expectKeyword' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(81,54): error TS2339: Property 'parseNamedType' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(82,24): error TS2339: Property 'parseDirectives' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/extended-parser.ts(83,26): error TS2339: Property 'parseSelectionSet' does not exist on type 'FragmentArgumentCompatibleParser'.
Error: packages/plugins/fragment-arguments/src/index.ts(8,55): error TS2554: Expected 0 arguments, but got 2.
Error: packages/plugins/fragment-arguments/src/index.ts(10,17): error TS2339: Property 'parseDocument' does not exist on type 'FragmentArgumentCompatibleParser'.

GraphQL.js 16 Tests

graphql-jit is not compatible with GraphQL.js 16

The plugin fails with the following error:

console.error
    {
      errors: [
        GraphQLError [Object] {
          message: "Cannot read property 'value' of undefined"
        }
      ]
    }

ApolloServer using the legacy execute(schema, ...args) call signature which makes it incompatible with GraphQL.js 16 (Now solved ✅ )

This breaks useApolloServerErrors with the following error, this must be fixed in Apollo, which imports execute from graphql-js directly.

Must provide the document.

       8 | describe('useApolloServerErrors', () => {
       9 |   const executeBoth = async (schema: GraphQLSchema, query: string, debug: boolean) => {
    > 10 |     const apolloServer = new ApolloServerBase({ schema, debug });
         |                          ^
      11 |     const envelopRuntime = envelop({ plugins: [useSchema(schema), useApolloServerErrors({ debug })] })({});
      12 |
      13 |     return {

Created apollographql/apollo-server#5662 for fixing this and also apollographql/apollo-server#5663 for addressing the ignored TypeScript errors.

ALso added a mock in the tests so we don't need to wait for those upstream changes.

@vercel
Copy link

vercel bot commented Aug 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/theguild/envelop/D3SMeCZWLAdP21dZvs5im8Axi8qv
✅ Preview: https://envelop-git-graphql-js-16-theguild.vercel.app

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2021

🦋 Changeset detected

Latest commit: d4a4ce6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 32 packages
Name Type
@envelop/core Minor
@envelop/apollo-server-errors Minor
@envelop/apollo-tracing Minor
@envelop/auth0 Minor
@envelop/dataloader Minor
@envelop/depth-limit Minor
@envelop/disable-introspection Minor
@envelop/execute-subscription-event Minor
@envelop/extended-validation Minor
@envelop/filter-operation-type Minor
@envelop/fragment-arguments Minor
@envelop/generic-auth Minor
@envelop/graphql-jit Minor
@envelop/graphql-middleware Minor
@envelop/graphql-modules Minor
@envelop/live-query Minor
@envelop/newrelic Minor
@envelop/opentelemetry Minor
@envelop/operation-field-permissions Minor
@envelop/parser-cache Minor
@envelop/persisted-operations Minor
@envelop/preload-assets Minor
@envelop/prometheus Minor
@envelop/rate-limiter Minor
@envelop/resource-limitations Minor
@envelop/response-cache Minor
@envelop/sentry Minor
@envelop/statsd Minor
@envelop/validation-cache Minor
@envelop/testing Minor
@envelop/types Minor
@envelop/response-cache-redis Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 27, 2021

The latest changes of this PR are available as alpha in npm (based on the declared changesets):

@envelop/core@1.5.0-alpha-6952fd9.0
@envelop/apollo-server-errors@1.1.0-alpha-6952fd9.0
@envelop/apollo-tracing@1.1.0-alpha-6952fd9.0
@envelop/auth0@1.1.0-alpha-6952fd9.0
@envelop/dataloader@1.1.0-alpha-6952fd9.0
@envelop/depth-limit@1.1.0-alpha-6952fd9.0
@envelop/disable-introspection@1.1.0-alpha-6952fd9.0
@envelop/execute-subscription-event@0.1.0-alpha-6952fd9.0
@envelop/extended-validation@1.2.0-alpha-6952fd9.0
@envelop/filter-operation-type@1.1.0-alpha-6952fd9.0
@envelop/fragment-arguments@1.1.0-alpha-6952fd9.0
@envelop/generic-auth@1.1.0-alpha-6952fd9.0
@envelop/graphql-jit@1.2.0-alpha-6952fd9.0
@envelop/graphql-middleware@1.1.0-alpha-6952fd9.0
@envelop/graphql-modules@1.1.0-alpha-6952fd9.0
@envelop/live-query@1.1.0-alpha-6952fd9.0
@envelop/newrelic@1.1.0-alpha-6952fd9.0
@envelop/opentelemetry@1.1.0-alpha-6952fd9.0
@envelop/operation-field-permissions@1.1.0-alpha-6952fd9.0
@envelop/parser-cache@2.1.0-alpha-6952fd9.0
@envelop/persisted-operations@2.1.0-alpha-6952fd9.0
@envelop/preload-assets@1.1.0-alpha-6952fd9.0
@envelop/prometheus@4.1.0-alpha-6952fd9.0
@envelop/rate-limiter@1.1.0-alpha-6952fd9.0
@envelop/resource-limitations@0.3.0-alpha-6952fd9.0
@envelop/response-cache@0.4.0-alpha-6952fd9.0
@envelop/response-cache-redis@0.1.2-alpha-6952fd9.0
@envelop/sentry@1.3.0-alpha-6952fd9.0
@envelop/statsd@0.2.0-alpha-6952fd9.0
@envelop/validation-cache@2.1.0-alpha-6952fd9.0
@envelop/testing@2.1.0-alpha-6952fd9.0
@envelop/types@1.4.0-alpha-6952fd9.0

@theguild-bot
Copy link
Collaborator

theguild-bot commented Aug 27, 2021

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.............................................: 100.00% ✓ 147256      ✗ 0    
     data_received......................................: 569 MB  11 MB/s
     data_sent..........................................: 32 MB   642 kB/s
     envelop_init.......................................: avg=898ns    min=200ns    med=500ns    max=715.3µs  p(90)=1.9µs    p(95)=2.1µs   
     ✓ { mode:envelop-cache-jit }.......................: avg=485ns    min=200ns    med=400ns    max=642.52µs p(90)=600ns    p(95)=800ns   
     ✓ { mode:envelop-just-cache }......................: avg=555ns    min=200ns    med=500ns    max=364.6µs  p(90)=700ns    p(95)=1.1µs   
     ✓ { mode:graphql-js }..............................: avg=1.07µs   min=300ns    med=600ns    max=124.4µs  p(90)=2µs      p(95)=2.1µs   
     ✓ { mode:prom-tracing }............................: avg=3.56µs   min=1.2µs    med=2µs      max=715.3µs  p(90)=7.1µs    p(95)=7.3µs   
     envelop_total......................................: avg=327.13µs min=0s       med=132.3µs  max=18.54ms  p(90)=507.29µs p(95)=1.51ms  
     ✓ { mode:envelop-cache-jit }.......................: avg=136.4µs  min=107.6µs  med=122.3µs  max=18.54ms  p(90)=137.6µs  p(95)=149.95µs
     ✓ { mode:envelop-just-cache }......................: avg=378.44µs min=312.3µs  med=329.1µs  max=12.79ms  p(90)=357.5µs  p(95)=425.5µs 
     ✓ { mode:graphql-js }..............................: avg=528.11µs min=415.5µs  med=448.6µs  max=13.32ms  p(90)=529.6µs  p(95)=1.01ms  
     ✓ { mode:prom-tracing }............................: avg=1.69ms   min=1.46ms   med=1.52ms   max=13.88ms  p(90)=1.7ms    p(95)=2.79ms  
     event_loop_lag.....................................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     ✓ { mode:envelop-cache-jit }.......................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     ✓ { mode:envelop-just-cache }......................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     ✓ { mode:graphql-js }..............................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     ✓ { mode:prom-tracing }............................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     graphql_context....................................: avg=4.58µs   min=2µs      med=3.3µs    max=1.88ms   p(90)=7.3µs    p(95)=8.4µs   
     ✓ { mode:envelop-cache-jit }.......................: avg=3.16µs   min=2µs      med=2.7µs    max=1.88ms   p(90)=3.5µs    p(95)=3.9µs   
     ✓ { mode:envelop-just-cache }......................: avg=3.79µs   min=2.4µs    med=3.2µs    max=1.64ms   p(90)=4.2µs    p(95)=4.4µs   
     ✓ { mode:graphql-js }..............................: avg=7.12µs   min=3.7µs    med=5.4µs    max=1.02ms   p(90)=8.69µs   p(95)=11.2µs  
     ✓ { mode:prom-tracing }............................: avg=8.09µs   min=5.8µs    med=6.9µs    max=1.17ms   p(90)=9.1µs    p(95)=9.6µs   
     graphql_execute....................................: avg=344.73µs min=72.5µs   med=286µs    max=17.85ms  p(90)=924.94µs p(95)=1.43ms  
     ✓ { mode:envelop-cache-jit }.......................: avg=94.78µs  min=72.5µs   med=84.6µs   max=17.85ms  p(90)=93.5µs   p(95)=103.25µs
     ✓ { mode:envelop-just-cache }......................: avg=330.79µs min=276.4µs  med=290.9µs  max=12.75ms  p(90)=313.8µs  p(95)=357.7µs 
     ✓ { mode:graphql-js }..............................: avg=352.02µs min=277.8µs  med=292.7µs  max=13.12ms  p(90)=323.97µs p(95)=391.21µs
     ✓ { mode:prom-tracing }............................: avg=1.58ms   min=1.37ms   med=1.43ms   max=13.51ms  p(90)=1.54ms   p(95)=2.67ms  
     graphql_parse......................................: avg=11.09µs  min=3µs      med=5.1µs    max=6.08ms   p(90)=24.8µs   p(95)=40.7µs  
     ✓ { mode:envelop-cache-jit }.......................: avg=5.94µs   min=3.4µs    med=4.89µs   max=3.21ms   p(90)=7.1µs    p(95)=8.3µs   
     ✓ { mode:envelop-just-cache }......................: avg=4.52µs   min=3µs      med=3.9µs    max=1.78ms   p(90)=4.7µs    p(95)=9.79µs  
     ✓ { mode:graphql-js }..............................: avg=14.99µs  min=8µs      med=11.4µs   max=2.02ms   p(90)=20.7µs   p(95)=24.9µs  
     ✓ { mode:prom-tracing }............................: avg=47.45µs  min=32.09µs  med=41.2µs   max=6.08ms   p(90)=49µs     p(95)=54.4µs  
     graphql_validate...................................: avg=60µs     min=25.3µs   med=30.6µs   max=13.64ms  p(90)=134.5µs  p(95)=145.3µs 
     ✓ { mode:envelop-cache-jit }.......................: avg=32.03µs  min=25.3µs   med=29.3µs   max=13.64ms  p(90)=33.9µs   p(95)=35.9µs  
     ✓ { mode:envelop-just-cache }......................: avg=38.77µs  min=26.3µs   med=29.8µs   max=12.42ms  p(90)=34.7µs   p(95)=37.6µs  
     ✓ { mode:graphql-js }..............................: avg=152.9µs  min=120.9µs  med=133.89µs max=8.81ms   p(90)=163.89µs p(95)=188.39µs
     ✓ { mode:prom-tracing }............................: avg=45.19µs  min=32µs     med=36.2µs   max=1.92ms   p(90)=41.3µs   p(95)=44.1µs  
     http_req_blocked...................................: avg=3.95µs   min=800ns    med=1.5µs    max=8.63ms   p(90)=2.4µs    p(95)=3.1µs   
     http_req_connecting................................: avg=779ns    min=0s       med=0s       max=8.43ms   p(90)=0s       p(95)=0s      
     http_req_duration..................................: avg=6.32ms   min=325.61µs med=4.69ms   max=103.41ms p(90)=13.95ms  p(95)=16.94ms 
       { expected_response:true }.......................: avg=6.32ms   min=325.61µs med=4.69ms   max=103.41ms p(90)=13.95ms  p(95)=16.94ms 
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=5.68ms   min=616.7µs  med=4.51ms   max=60.4ms   p(90)=9.46ms   p(95)=10.64ms 
     ✓ { mode:envelop-cache-jit }.......................: avg=3.51ms   min=325.61µs med=2.46ms   max=33.79ms  p(90)=8.25ms   p(95)=11.02ms 
     ✓ { mode:envelop-just-cache }......................: avg=5.96ms   min=557.5µs  med=4.7ms    max=54.78ms  p(90)=9.71ms   p(95)=12.61ms 
     ✓ { mode:graphql-js }..............................: avg=8ms      min=698.29µs med=6.29ms   max=67.77ms  p(90)=12.96ms  p(95)=16.9ms  
     ✓ { mode:prom-tracing }............................: avg=19.24ms  min=2.15ms   med=16.84ms  max=103.41ms p(90)=32.09ms  p(95)=33.8ms  
     http_req_failed....................................: 0.00%   ✓ 0           ✗ 73628
     http_req_receiving.................................: avg=56.55µs  min=13.4µs   med=25.2µs   max=36.33ms  p(90)=38.2µs   p(95)=44.8µs  
     http_req_sending...................................: avg=64.65µs  min=5.3µs    med=9.6µs    max=25.52ms  p(90)=19.8µs   p(95)=26.8µs  
     http_req_tls_handshaking...........................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...................................: avg=6.19ms   min=298.2µs  med=4.59ms   max=90.62ms  p(90)=13.53ms  p(95)=16.82ms 
     http_reqs..........................................: 73628   1472.238627/s
     iteration_duration.................................: avg=6.78ms   min=572.71µs med=5.09ms   max=103.9ms  p(90)=14.83ms  p(95)=17.41ms 
     iterations.........................................: 73628   1472.238627/s
     vus................................................: 0       min=0         max=19 
     vus_max............................................: 40      min=40        max=40 

scripts/match-graphql.js Outdated Show resolved Hide resolved
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.

3 participants