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

Unique execution context with the correct request object #3237

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

ardatan
Copy link
Collaborator

@ardatan ardatan commented Apr 15, 2024

Closes #3238

Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: b229436

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

This PR includes changesets to release 10 packages
Name Type
graphql-yoga Patch
apollo-federation-gateway-with-yoga Patch
apollo-subgraph-with-yoga Patch
graphql-lambda Patch
cloudflare-advanced Patch
cloudflare Patch
functions Patch
hackernews Patch
nextjs-app Patch
hello-world-benchmark 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

Copy link
Contributor

github-actions bot commented Apr 15, 2024

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

Copy link
Contributor

github-actions bot commented Apr 15, 2024

✅ Benchmark Results

     ✓ no_errors{mode:graphql}
     ✓ expected_result{mode:graphql}
     ✓ no_errors{mode:graphql-jit}
     ✓ expected_result{mode:graphql-jit}
     ✓ no_errors{mode:graphql-response-cache}
     ✓ expected_result{mode:graphql-response-cache}
     ✓ no_errors{mode:graphql-no-parse-validate-cache}
     ✓ expected_result{mode:graphql-no-parse-validate-cache}

     checks.......................................: 100.00% ✓ 401190      ✗ 0     
     data_received................................: 1.6 GB  14 MB/s
     data_sent....................................: 81 MB   675 kB/s
     http_req_blocked.............................: avg=1.42µs   min=942ns    med=1.27µs   max=306.11µs p(90)=1.89µs   p(95)=2.1µs   
     http_req_connecting..........................: avg=2ns      min=0s       med=0s       max=130.62µs p(90)=0s       p(95)=0s      
     http_req_duration............................: avg=387.89µs min=219.02µs med=344.04µs max=23.49ms  p(90)=546.37µs p(95)=566.19µs
       { expected_response:true }.................: avg=387.89µs min=219.02µs med=344.04µs max=23.49ms  p(90)=546.37µs p(95)=566.19µs
     ✓ { mode:graphql-jit }.......................: avg=288.16µs min=219.02µs med=265.97µs max=17.95ms  p(90)=296.89µs p(95)=310.24µs
     ✓ { mode:graphql-no-parse-validate-cache }...: avg=576.46µs min=480.57µs med=545.66µs max=10.08ms  p(90)=586.93µs p(95)=623.52µs
     ✓ { mode:graphql-response-cache }............: avg=368.71µs min=294.45µs med=349.53µs max=9.43ms   p(90)=380.46µs p(95)=391.17µs
     ✓ { mode:graphql }...........................: avg=385.18µs min=296.96µs med=349.18µs max=23.49ms  p(90)=398.04µs p(95)=452µs   
     http_req_failed..............................: 0.00%   ✓ 0           ✗ 200595
     http_req_receiving...........................: avg=33.23µs  min=16.91µs  med=33.01µs  max=6.51ms   p(90)=39.07µs  p(95)=41.04µs 
     http_req_sending.............................: avg=7.99µs   min=5.73µs   med=7.1µs    max=343.4µs  p(90)=10.57µs  p(95)=11.36µs 
     http_req_tls_handshaking.....................: avg=0s       min=0s       med=0s       max=0s       p(90)=0s       p(95)=0s      
     http_req_waiting.............................: avg=346.66µs min=184.7µs  med=303.42µs max=23.35ms  p(90)=505.28µs p(95)=522.94µs
     http_reqs....................................: 200595  1671.608709/s
     iteration_duration...........................: avg=593.41µs min=388.05µs med=546.07µs max=24.3ms   p(90)=755.07µs p(95)=778.74µs
     iterations...................................: 200595  1671.608709/s
     vus..........................................: 1       min=1         max=1   
     vus_max......................................: 2       min=2         max=2   

Copy link
Contributor

github-actions bot commented Apr 15, 2024

💻 Website Preview

The latest changes are available as preview in: https://b803f2c4.graphql-yoga.pages.dev

@ardatan ardatan marked this pull request as ready for review April 15, 2024 11:43
Copy link
Contributor

github-actions bot commented Apr 15, 2024

🚀 Snapshot Release (rc)

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

Package Version Info
graphql-yoga-cloud-run-guide 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/apollo-link 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/urql-exchange 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
graphql-yoga 5.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/nestjs-federation 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apollo-inline-trace 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-apq 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-csrf-prevention 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-defer-stream 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-disable-introspection 2.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-graphql-sse 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-jwt 2.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-persisted-operations 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-prometheus 4.2.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-response-cache 3.5.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/plugin-sofa 3.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎
@graphql-yoga/render-graphiql 5.3.1-rc-20240415115405-cf990492 npm ↗︎ unpkg ↗︎

@ardatan ardatan merged commit 3324bba into main Apr 15, 2024
25 of 28 checks passed
@ardatan ardatan deleted the repro-unique-exec-ctx branch April 15, 2024 13:20
@kireerik
Copy link

kireerik commented May 9, 2024

This seems to break routeOptions(.config) (https://fastify.dev/docs/latest/Reference/Request/) for fastify.

@ardatan
Copy link
Collaborator Author

ardatan commented May 9, 2024

Could you create a new issue with details and a reproduction? @kireerik

@kireerik
Copy link

kireerik commented Jun 19, 2024

We are getting the following error:

ERR TypeError: Cannot read properties of undefined (reading 'config')
    at Object.context (...)
    at node_modules/.pnpm/graphql-yoga@5.4.0_graphql@16.8.2/node_modules/graphql-yoga/esm/server.js:114:44
    at onContextBuilding (node_modules/.pnpm/@envelop+core@5.0.1/node_modules/@envelop/core/esm/plugins/use-extend-context.js:3:30)
    at Object.contextFactory (node_modules/.pnpm/@envelop+core@5.0.1/node_modules/@envelop/core/esm/orchestrator.js:203:51)
    at processRequest (node_modules/.pnpm/graphql-yoga@5.4.0_graphql@16.8.2/node_modules/graphql-yoga/esm/process-request.js:43:42)
    at YogaServer.getResultForParams (node_modules/.pnpm/graphql-yoga@5.4.0_graphql@16.8.2/node_modules/graphql-yoga/esm/server.js:276:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handle (node_modules/.pnpm/graphql-yoga@5.4.0_graphql@16.8.2/node_modules/graphql-yoga/esm/server.js:346:25)
    at async Object.handler (...)

The relevant part looks like this:

const { handleNodeRequest } = createYoga({
	context: ({ request }) => ({
		...request.routeOptions.config
	})
})

// Fastify handler:
async (request, reply) => {
	const {
		headers, status, body
	} =
		await handleNodeRequest(request, { request })

	headers.forEach((value, key) =>
		reply.header(key, value)
	)

	return reply.status(status).send(body)
}

@ardatan
Copy link
Collaborator Author

ardatan commented Jun 19, 2024

As I wrote in the previous comment, could you create a new issue with a reproduction by following our issue template there?
Thanks!

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.

[Cloudflare Workers] request in the context is never updated per each request
3 participants