You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 馃浉 serverimport{parse,ExecutionArgs}from'graphql';import{createHandler}from'graphql-sse';import{schema}from'./my-graphql';// a unique GraphQL execution ID used for representing// a query in the persisted queries store. when subscribing// you should use the `SubscriptionPayload.query` to transmit the idtypeQueryID=string;constqueriesStore: Record<QueryID,ExecutionArgs>={iWantTheGreetings: {
schema,// you may even provide different schemas in the queries storedocument: parse('subscription Greetings { greetings }'),},};exportconsthandler=createHandler({onSubscribe: (_req,params)=>{constpersistedQuery=queriesStore[String(params.extensions?.persistedQuery)];if(persistedQuery){return{
...persistedQuery,variableValues: params.variables,// use the variables from the clientcontextValue: undefined,};}// for extra security only allow the queries from the storereturn[null,{status: 404,statusText: 'Not Found'}];},});
onSubscribe would return a ExecutionArgs result, leading graphql to execute the expected resolver.
However in current implementation, the returned result from above example is treated as ExecutionResult, hence the resolver is not triggered.
Hi @enisdenjo, first of all, thank you for maintaining such an awesome project!
I would like to report an issue related to persisted queries support.
As described in the recipes:
onSubscribe
would return aExecutionArgs
result, leading graphql to execute the expected resolver.However in current implementation, the returned result from above example is treated as ExecutionResult, hence the resolver is not triggered.
graphql-sse/src/handler.ts
Lines 587 to 600 in d4890f1
graphql-sse/src/handler.ts
Lines 1107 to 1110 in d4890f1
Please let me know if I missed anything, and if more details are needed, thank you!
The text was updated successfully, but these errors were encountered: