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

Deprecate '.start' and '.stop' methods for common package #1374

Closed
wants to merge 1 commit into from

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Jul 8, 2022

Handling a platform-specific logic inside Yoga is a bit confusing. This PR implements EventListenerObject.handleEvent method for Yoga so Yoga can be used as an event listener directly then it can be used with any event target.
And having an extra .start(), .stop() doesn't make sense in this case.

This PR also adds a deprecation notice to those existing methods to encourage people for the new usage.

import { createServer } from '@graphql-yoga/common'

const yoga = createServer({
  //...
})

//Before: yoga.start();
self.addEventListener('fetch', yoga)

//Before: yoga.stop();
self.removeEventListener('fetch', yoga)

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2022

🦋 Changeset detected

Latest commit: 1719d45

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

This PR includes changesets to release 6 packages
Name Type
@graphql-yoga/common Minor
@graphql-yoga/render-graphiql Major
cloudflare-advanced Patch
cloudflare Patch
service-worker Patch
sveltekit 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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2022

✅ Benchmark Results

     ✓ no_errors
     ✓ expected_result

     checks.........................: 100.00% ✓ 231774      ✗ 0     
     data_received..................: 31 MB   1.0 MB/s
     data_sent......................: 13 MB   444 kB/s
     http_req_blocked...............: avg=1.11µs   min=700ns   med=1µs     max=1.8ms   p(90)=1.3µs   p(95)=1.7µs  
     http_req_connecting............: avg=14ns     min=0s      med=0s      max=1.65ms  p(90)=0s      p(95)=0s     
   ✓ http_req_duration..............: avg=193.12µs min=136.1µs med=172.8µs max=16.8ms  p(90)=213.1µs p(95)=240.4µs
       { expected_response:true }...: avg=193.12µs min=136.1µs med=172.8µs max=16.8ms  p(90)=213.1µs p(95)=240.4µs
     http_req_failed................: 0.00%   ✓ 0           ✗ 115887
     http_req_receiving.............: avg=17.18µs  min=10.1µs  med=16µs    max=5.26ms  p(90)=20.2µs  p(95)=22.7µs 
     http_req_sending...............: avg=5.69µs   min=4µs     med=4.59µs  max=5.55ms  p(90)=6.3µs   p(95)=9.4µs  
     http_req_tls_handshaking.......: avg=0s       min=0s      med=0s      max=0s      p(90)=0s      p(95)=0s     
     http_req_waiting...............: avg=170.24µs min=118µs   med=152.1µs max=16.52ms p(90)=185.9µs p(95)=209.4µs
     http_reqs......................: 115887  3862.736983/s
     iteration_duration.............: avg=254.12µs min=188.1µs med=230µs   max=17.44ms p(90)=284.6µs p(95)=318.5µs
     iterations.....................: 115887  3862.736983/s
     vus............................: 1       min=1         max=1   
     vus_max........................: 1       min=1         max=1   

@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2022

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

@graphql-yoga/common@2.12.0-canary-cb85c57.0
graphql-yoga@2.13.0-canary-cb85c57.0
@graphql-yoga/node@2.13.0-canary-cb85c57.0
@graphql-yoga/render-graphiql@2.13.0-canary-cb85c57.0

start() {
self.addEventListener('fetch', this.fetchEventListener as EventListener)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we also add console.warn for the depcreation warning.

@theguild-bot theguild-bot mentioned this pull request Jul 14, 2022
@ardatan ardatan closed this Jul 19, 2022
@ardatan ardatan deleted the better-cf-dx-2 branch July 20, 2022 15:54
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.

None yet

2 participants