Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/apollo-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const getEnveloped = envelop({
});

const executor: GatewayExecutor = async requestContext => {
const { schema, execute, contextFactory } = getEnveloped({ req: requestContext.request.http });
const { schema, execute, contextFactory } = getEnveloped({
req: requestContext.request.http,
});

return execute({
schema,
Expand Down
4 changes: 3 additions & 1 deletion examples/azure-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const getEnveloped = envelop({
});

export const index: AzureFunction = async (context: Context, req: HttpRequest): Promise<void> => {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/cloudflare-workers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const getEnveloped = envelop({
});

router.add('POST', '/graphql', async (req, res) => {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
5 changes: 4 additions & 1 deletion examples/express-graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ const app = express();
app.use(
'/graphql',
graphqlHTTP(async (req, res) => {
const { parse, validate, contextFactory, execute } = getEnveloped({ req, res });
const { parse, validate, contextFactory, execute } = getEnveloped({
req,
res,
});
return {
schema,
graphiql: true,
Expand Down
4 changes: 3 additions & 1 deletion examples/google-cloud-functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const getEnveloped = envelop({

// https://firebase.google.com/docs/functions/typescript
export const helloWorld = functions.https.onRequest(async (req, res) => {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/graphql-helix-auth0/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/graphql-helix-defer-stream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/graphql-helix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/lambda-aws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const getEnveloped = envelop({
});

export const lambdaHandler: APIGatewayProxyHandler = async event => {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req: event });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req: event,
});
const request = {
body: event.body,
headers: event.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/nexus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
4 changes: 3 additions & 1 deletion examples/simple-http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const getEnveloped = envelop({
});

const server = createServer((req, res) => {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
let payload = '';

req.on('data', chunk => {
Expand Down
4 changes: 3 additions & 1 deletion examples/typegraphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down
15 changes: 11 additions & 4 deletions examples/with-esm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ app.route({
method: ['GET', 'POST'],
url: '/graphql',
async handler(req, res) {
const { parse, validate, contextFactory, execute, schema } = getEnveloped({ req });
const { parse, validate, contextFactory, execute, schema } = getEnveloped({
req,
});
const request = {
body: req.body,
headers: req.headers,
Expand Down Expand Up @@ -70,6 +72,11 @@ app.route({
},
});

app.listen(3000, () => {
console.log(`GraphQL server is running in http://127.0.0.1:3000/graphql.`);
});
app.listen(
{
port: 3000,
},
() => {
console.log(`GraphQL server is running in http://127.0.0.1:3000/graphql.`);
},
);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"@types/jest": "30.0.0",
"@types/k6": "1.4.0",
"@types/node": "24.10.4",
"@typescript-eslint/eslint-plugin": "8.48.1",
"@typescript-eslint/parser": "8.48.1",
"@typescript-eslint/eslint-plugin": "8.50.0",
"@typescript-eslint/parser": "8.50.0",
"bob-the-bundler": "7.0.1",
"caniuse-lite": "^1.0.30001692",
"chalk": "5.6.2",
Expand Down
14 changes: 11 additions & 3 deletions packages/core/src/plugins/use-error-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ export const useErrorHandler = <ContextType extends Record<string, any>>(
onValidate() {
return function onValidateEnd({ valid, result, context }) {
if (valid === false && result.length > 0) {
errorHandler({ errors: result as Error[], context, phase: 'validate' });
errorHandler({
errors: result as Error[],
context,
phase: 'validate',
});
}
};
},
Expand All @@ -64,8 +68,12 @@ export const useErrorHandler = <ContextType extends Record<string, any>>(
if (isGraphQLError(error)) {
errorHandler({ errors: [error], context, phase: 'context' });
} else {
// @ts-expect-error its not an error at this point so we just create a new one - can we handle this better?
errorHandler({ errors: [new Error(error)], context, phase: 'context' });
errorHandler({
// @ts-expect-error its not an error at this point so we just create a new one - can we handle this better?
errors: [new Error(error)],
context,
phase: 'context',
});
}
});
},
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/plugins/use-masked-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const makeHandleResult =
setResult: (result: ExecutionResult) => void;
}) => {
if (result.errors != null) {
setResult({ ...result, errors: result.errors.map(error => maskError(error, message)) });
setResult({
...result,
errors: result.errors.map(error => maskError(error, message)),
});
}
};

Expand Down
Loading