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

feat: allow enableIf to accept a funciton #888

Merged
merged 5 commits into from
Oct 27, 2021
Merged

feat: allow enableIf to accept a funciton #888

merged 5 commits into from
Oct 27, 2021

Conversation

saihaj
Copy link
Collaborator

@saihaj saihaj commented Oct 26, 2021

Closes #875

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2021

🦋 Changeset detected

Latest commit: 82d6c13

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

This PR includes changesets to release 2 packages
Name Type
@envelop/core Minor
@envelop/operation-field-permissions 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

@vercel
Copy link

vercel bot commented Oct 26, 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/FSQMHBhkumTcNtp4Afwed7in7J5s
✅ Preview: https://envelop-git-issue-875-theguild.vercel.app

@saihaj
Copy link
Collaborator Author

saihaj commented Oct 26, 2021

@dotansimha I am not sure how to test if a plugin's init is called or not : )?

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 26, 2021

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

@theguild-bot
Copy link
Collaborator

theguild-bot commented Oct 26, 2021

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.............................................: 100.00% ✓ 135924     ✗ 0    
     data_received......................................: 525 MB  11 MB/s
     data_sent..........................................: 30 MB   593 kB/s
     envelop_init.......................................: avg=1.03µs   min=100ns    med=500ns   max=1.51ms   p(90)=1.8µs    p(95)=2.4µs   
     ✓ { mode:envelop-cache-jit }.......................: avg=379ns    min=100ns    med=300ns   max=36.6µs   p(90)=600ns    p(95)=800ns   
     ✓ { mode:envelop-just-cache }......................: avg=715ns    min=200ns    med=500ns   max=1.51ms   p(90)=700ns    p(95)=1.35µs  
     ✓ { mode:graphql-js }..............................: avg=1.26µs   min=300ns    med=700ns   max=1.22ms   p(90)=1.8µs    p(95)=2µs     
     ✓ { mode:prom-tracing }............................: avg=4.58µs   min=1.5µs    med=2.4µs   max=1.37ms   p(90)=7.6µs    p(95)=7.9µs   
     envelop_total......................................: avg=345.56µs min=0s       med=141.6µs max=17.18ms  p(90)=535.8µs  p(95)=1.62ms  
     ✓ { mode:envelop-cache-jit }.......................: avg=143.25µs min=115.7µs  med=133.4µs max=13.23ms  p(90)=149.7µs  p(95)=161.2µs 
     ✓ { mode:envelop-just-cache }......................: avg=406.4µs  min=317.8µs  med=344.9µs max=12.42ms  p(90)=383.72µs p(95)=466.46µs
     ✓ { mode:graphql-js }..............................: avg=574.8µs  min=432.8µs  med=469.8µs max=15.75ms  p(90)=559.55µs p(95)=940.7µs 
     ✓ { mode:prom-tracing }............................: avg=1.79ms   min=1.5ms    med=1.63ms  max=17.18ms  p(90)=1.78ms   p(95)=2.94ms  
     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.79µs   min=1.9µs    med=3.2µs   max=1.97ms   p(90)=7.7µs    p(95)=8.5µs   
     ✓ { mode:envelop-cache-jit }.......................: avg=2.8µs    min=1.9µs    med=2.6µs   max=795.61µs p(90)=3.4µs    p(95)=3.7µs   
     ✓ { mode:envelop-just-cache }......................: avg=4.16µs   min=2.29µs   med=3.4µs   max=816.21µs p(90)=5µs      p(95)=5.4µs   
     ✓ { mode:graphql-js }..............................: avg=7.51µs   min=3.9µs    med=5.9µs   max=931.61µs p(90)=8.8µs    p(95)=13.7µs  
     ✓ { mode:prom-tracing }............................: avg=10.51µs  min=6.5µs    med=7.6µs   max=1.97ms   p(90)=10.3µs   p(95)=10.89µs 
     graphql_execute....................................: avg=374.55µs min=82.4µs   med=297.7µs max=16.75ms  p(90)=1.43ms   p(95)=1.54ms  
     ✓ { mode:envelop-cache-jit }.......................: avg=102.73µs min=82.4µs   med=94.8µs  max=13.19ms  p(90)=105.4µs  p(95)=115.6µs 
     ✓ { mode:envelop-just-cache }......................: avg=359.64µs min=282.7µs  med=305.5µs max=12.38ms  p(90)=337.5µs  p(95)=391.68µs
     ✓ { mode:graphql-js }..............................: avg=381.06µs min=283µs    med=307.1µs max=15.61ms  p(90)=343.6µs  p(95)=395.65µs
     ✓ { mode:prom-tracing }............................: avg=1.67ms   min=1.41ms   med=1.54ms  max=16.75ms  p(90)=1.63ms   p(95)=2.78ms  
     graphql_parse......................................: avg=11.43µs  min=3µs      med=4.8µs   max=10.1ms   p(90)=27.7µs   p(95)=42.2µs  
     ✓ { mode:envelop-cache-jit }.......................: avg=5.38µs   min=3.2µs    med=4.7µs   max=2.2ms    p(90)=6.7µs    p(95)=7.3µs   
     ✓ { mode:envelop-just-cache }......................: avg=5.7µs    min=3µs      med=3.9µs   max=10.1ms   p(90)=4.89µs   p(95)=10.6µs  
     ✓ { mode:graphql-js }..............................: avg=15.61µs  min=7.5µs    med=11.9µs  max=2.56ms   p(90)=21µs     p(95)=24.4µs  
     ✓ { mode:prom-tracing }............................: avg=48.33µs  min=34µs     med=42.4µs  max=1.83ms   p(90)=51.7µs   p(95)=56.59µs 
     graphql_validate...................................: avg=60.67µs  min=26.2µs   med=31.5µs  max=14.29ms  p(90)=139.3µs  p(95)=149.2µs 
     ✓ { mode:envelop-cache-jit }.......................: avg=31.95µs  min=26.2µs   med=30.5µs  max=2.78ms   p(90)=34.8µs   p(95)=36.79µs 
     ✓ { mode:envelop-just-cache }......................: avg=36.16µs  min=26.6µs   med=30.4µs  max=11.58ms  p(90)=36.2µs   p(95)=39.7µs  
     ✓ { mode:graphql-js }..............................: avg=169.34µs min=125.1µs  med=139.6µs max=14.29ms  p(90)=168.8µs  p(95)=195.4µs 
     ✓ { mode:prom-tracing }............................: avg=49.97µs  min=32.7µs   med=37.1µs  max=8.08ms   p(90)=43.4µs   p(95)=46.2µs  
     http_req_blocked...................................: avg=4.64µs   min=900ns    med=1.7µs   max=11.59ms  p(90)=2.6µs    p(95)=3.2µs   
     http_req_connecting................................: avg=1.55µs   min=0s       med=0s      max=5.77ms   p(90)=0s       p(95)=0s      
     http_req_duration..................................: avg=6.85ms   min=339.1µs  med=4.88ms  max=96.03ms  p(90)=15.73ms  p(95)=17.94ms 
       { expected_response:true }.......................: avg=6.85ms   min=339.1µs  med=4.88ms  max=96.03ms  p(90)=15.73ms  p(95)=17.94ms 
     ✓ { mode:envelop-cache-and-no-internal-tracing }...: avg=5.81ms   min=612.81µs med=4.59ms  max=48.71ms  p(90)=9.71ms   p(95)=11.23ms 
     ✓ { mode:envelop-cache-jit }.......................: avg=3.79ms   min=339.1µs  med=2.59ms  max=48.1ms   p(90)=9.23ms   p(95)=11.87ms 
     ✓ { mode:envelop-just-cache }......................: avg=6.47ms   min=703.01µs med=4.96ms  max=83.13ms  p(90)=10.83ms  p(95)=14.06ms 
     ✓ { mode:graphql-js }..............................: avg=9.72ms   min=758.21µs med=7.47ms  max=70.31ms  p(90)=16.01ms  p(95)=19.56ms 
     ✓ { mode:prom-tracing }............................: avg=19.91ms  min=3.23ms   med=17.71ms max=96.03ms  p(90)=33.92ms  p(95)=35.8ms  
     http_req_failed....................................: 0.00%   ✓ 0          ✗ 67962
     http_req_receiving.................................: avg=63.28µs  min=13.6µs   med=27µs    max=23.78ms  p(90)=40.2µs   p(95)=46.4µs  
     http_req_sending...................................: avg=70.78µs  min=5.5µs    med=10.3µs  max=23.44ms  p(90)=20.29µs  p(95)=27.5µs  
     http_req_tls_handshaking...........................: avg=0s       min=0s       med=0s      max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting...................................: avg=6.71ms   min=291.2µs  med=4.79ms  max=95.97ms  p(90)=15.39ms  p(95)=17.83ms 
     http_reqs..........................................: 67962   1358.84413/s
     iteration_duration.................................: avg=7.35ms   min=585.31µs med=5.28ms  max=96.45ms  p(90)=16.37ms  p(95)=18.45ms 
     iterations.........................................: 67962   1358.84413/s
     vus................................................: 10      min=10       max=20 
     vus_max............................................: 40      min=40       max=40 

@dotansimha
Copy link
Collaborator

dotansimha commented Oct 26, 2021

@dotansimha I am not sure how to test if a plugin's init is called or not : )?

You can create a "fake plugin" that is only a jest.fn().mockImplementation(() => ({}) and check if it was called.

@dotansimha
Copy link
Collaborator

@saihaj i guess it needs a rebase?

@saihaj
Copy link
Collaborator Author

saihaj commented Oct 27, 2021

@saihaj i guess it needs a rebase?

The failing ci is related to graphql/graphql-js#3340

@saihaj
Copy link
Collaborator Author

saihaj commented Oct 27, 2021

@dotansimha should be good now

@dotansimha dotansimha merged commit 3458917 into main Oct 27, 2021
@dotansimha dotansimha deleted the issue-875 branch October 27, 2021 17:20
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.

Allow enableIf to receive a function that returns a plugin
3 participants