Open snigdha920 opened 1 month ago
The error is here: https://github.com/dotansimha/graphql-yoga/blob/855600cd6f39102f8bdfd5d9f54bf62c9a26bc0f/packages/plugins/prometheus/src/index.ts#L107
When using subscriptions there is no request
in the context, and we still try to use it as a key for setting params, adding something like:
// When parsing subscriptions, there is no request
if (!request) {
return;
}
paramsByRequest.set(request, {
document,
operationName: operationAST?.name?.value,
operationType: operationAST?.operation
});
fixes the issue.
But I'm also not sure why we're using request
as a key, in the original @envelop/prometheus
they use the entire context
, which already takes care of this condition:
So perhaps the best fix is to use the context
as the key?
Right now I'm using the custom minimal metrics plugin, because I only really need the /metrics
endpoint: https://github.com/snigdha920/bun-graphql-yoga-prometheus/tree/custom-plugin
Describe the bug
On installing the prometheus plugin, subscriptions fail with the error:
If we comment out the plugin, subscriptions work again.
If we use the plugins from
@envelop/prometheus
, the subscriptions work again, but http://localhost:4000/metrics gives a 404.What is the correct way to use the plugin with graphql-ws subscriptions?
I can also open a PR but will need guidance on what the fix is.
Your Example Website or App
https://github.com/snigdha920/bun-graphql-yoga-prometheus/tree/main
Steps to Reproduce the Bug or Issue
bun dev
and this error in the console:
usePrometheus
plugin, run the subscription again, works as expectedExpected behavior
I expected the subscription to return data
Screenshots or Videos
No response
Platform
@graphql-yoga/*
version(s): 5.6.1Additional context
No response