diff --git a/e2e/tests/azure-function.ts b/e2e/tests/azure-function.ts
index 2c2b6f041e..da3a587312 100644
--- a/e2e/tests/azure-function.ts
+++ b/e2e/tests/azure-function.ts
@@ -154,7 +154,7 @@ export const azureFunctionDeployment: DeploymentConfiguration<{
],
http20Enabled: true,
httpLoggingEnabled: true,
- linuxFxVersion: 'node|18',
+ linuxFxVersion: 'node|20',
},
},
{
diff --git a/e2e/utils.ts b/e2e/utils.ts
index 5f7b1d901d..50681fd46d 100644
--- a/e2e/utils.ts
+++ b/e2e/utils.ts
@@ -67,14 +67,14 @@ export async function assertGraphiQL(endpoint: string) {
},
});
+ const html = await response.text();
+
if (response.status !== 200) {
- console.warn(`⚠️ Invalid GraphiQL status code:`, response.status);
+ console.warn(`⚠️ Invalid GraphiQL status code:`, response.status, ', body:', html);
throw new Error(`Failed to locate GraphiQL: invalid status code (${response.status})`);
}
- const html = await response.text();
-
if (!html.includes('
Yoga GraphiQL')) {
console.warn(`⚠️ Invalid GraphiQL body:`, html);
diff --git a/examples/azure-function/build.js b/examples/azure-function/build.js
index 5c4c5e79bc..b6c15de986 100644
--- a/examples/azure-function/build.js
+++ b/examples/azure-function/build.js
@@ -10,7 +10,8 @@ async function main() {
minify: false,
bundle: true,
platform: 'node',
- target: 'node14',
+ target: 'node18',
+ external: ['@azure/functions-core'],
});
writeFileSync(
diff --git a/examples/azure-function/package.json b/examples/azure-function/package.json
index 595b61d8e2..503c51e16e 100644
--- a/examples/azure-function/package.json
+++ b/examples/azure-function/package.json
@@ -10,7 +10,7 @@
"graphql-yoga": "workspace:*"
},
"devDependencies": {
- "@azure/functions": "4.0.0",
+ "@azure/functions": "4.5.0",
"esbuild": "0.17.19",
"tslib": "2.6.3",
"typescript": "5.5.3"
diff --git a/examples/azure-function/src/index.ts b/examples/azure-function/src/index.ts
index f15b08a78e..e7489b2ea4 100644
--- a/examples/azure-function/src/index.ts
+++ b/examples/azure-function/src/index.ts
@@ -1,51 +1,23 @@
import { createSchema, createYoga } from 'graphql-yoga';
-import { AzureFunction, Context, HttpRequest } from '@azure/functions';
+import { app, InvocationContext } from '@azure/functions';
-const httpTrigger: AzureFunction = async function (
- context: Context,
- req: HttpRequest,
-): Promise {
- const app = createYoga({
- logging: {
- debug: context.log.verbose,
- error: context.log.error,
- info: context.log.info,
- warn: context.log.warn,
- },
- graphqlEndpoint: '/api/yoga',
- schema: createSchema({
- typeDefs: /* GraphQL */ `
- type Query {
- greetings: String
- }
- `,
- resolvers: {
- Query: {
- greetings: () => 'This is the `greetings` field of the root `Query` type',
- },
+const yoga = createYoga({
+ graphqlEndpoint: '/api/yoga',
+ schema: createSchema({
+ typeDefs: /* GraphQL */ `
+ type Query {
+ greetings: String
+ }
+ `,
+ resolvers: {
+ Query: {
+ greetings: () => 'This is the `greetings` field of the root `Query` type',
},
- }),
- });
- context.log('HTTP trigger function processed a request.');
-
- const response = await app.fetch(req.url, {
- method: req.method?.toString(),
- body: req.rawBody,
- headers: req.headers,
- });
-
- const headersObj = Object.fromEntries(response.headers.entries());
-
- context.log('GraphQL Yoga response headers:', headersObj);
-
- const responseText = await response.text();
- context.log('GraphQL Yoga response text:', responseText);
-
- context.res = {
- status: response.status,
- body: responseText,
- headers: headersObj,
- };
-};
+ },
+ }),
+});
-export default httpTrigger;
+app.http('yoga', {
+ method: ['GET', 'POST'],
+ handler: yoga,
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 333d1120e2..68b4ef1f88 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -326,8 +326,8 @@ importers:
version: link:../../packages/graphql-yoga/dist
devDependencies:
'@azure/functions':
- specifier: 4.0.0
- version: 4.0.0
+ specifier: 4.5.0
+ version: 4.5.0
esbuild:
specifier: 0.17.19
version: 0.17.19
@@ -2810,8 +2810,8 @@ packages:
'@aws-sdk/util-utf8-browser@3.259.0':
resolution: {integrity: sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw==}
- '@azure/functions@4.0.0':
- resolution: {integrity: sha512-NsL1vbYtsh19eA6d3Syo9bP8d1JAguE9nRd9AFBTcK+lhbRzKvKQ98efiGz21ug2Cm526SMet0imxUSykviEHA==}
+ '@azure/functions@4.5.0':
+ resolution: {integrity: sha512-WNCiOHMQEZpezxgThD3o2McKEjUEljtQBvdw4X4oE5714eTw76h33kIj0660ZJGEnxYSx4dx18oAbg5kLMs9iQ==}
engines: {node: '>=18.0'}
'@babel/code-frame@7.24.7':
@@ -8846,6 +8846,10 @@ packages:
resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==}
engines: {node: '>= 0.6'}
+ cookie@0.6.0:
+ resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==}
+ engines: {node: '>= 0.6'}
+
cookiejar@2.1.4:
resolution: {integrity: sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==}
@@ -17617,8 +17621,9 @@ snapshots:
dependencies:
tslib: 2.6.3
- '@azure/functions@4.0.0':
+ '@azure/functions@4.5.0':
dependencies:
+ cookie: 0.6.0
long: 4.0.0
undici: 5.28.4
@@ -25295,6 +25300,8 @@ snapshots:
cookie@0.5.0: {}
+ cookie@0.6.0: {}
+
cookiejar@2.1.4: {}
cookies@0.8.0: