Skip to content

Commit

Permalink
Do not assign request if already defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Oct 13, 2023
1 parent abed431 commit daaace6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 1 addition & 4 deletions examples/service-worker/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { createSchema, createYoga, Repeater } from 'graphql-yoga';

// We can define GraphQL Route dynamically using env vars.
declare let GRAPHQL_ROUTE: string;

const yoga = createYoga({
graphqlEndpoint: GRAPHQL_ROUTE || '/graphql',
graphqlEndpoint: globalThis.GRAPHQL_ROUTE || '/graphql',
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
Expand Down
13 changes: 9 additions & 4 deletions packages/graphql-yoga/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,14 @@ export class YogaServer<
}

if (result == null) {
const additionalContext = {
request,
params,
};
const additionalContext = args[0]?.request
? {
params,
}
: {
request,
params,
};

const initialContext = args[0]
? batched
Expand Down Expand Up @@ -548,6 +552,7 @@ export class YogaServer<
{
params: requestParserResult,
request,
batched: false,
},
serverContext,
))) as ResultProcessorInput;
Expand Down

0 comments on commit daaace6

Please sign in to comment.