-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
172 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import fs from 'fs'; | ||
import { defineConfig } from '@graphql-hive/gateway'; | ||
|
||
const SUPERGRAPH_PATH = process.env['SUPERGRAPH_PATH'] || 'supergraph.graphql'; | ||
|
||
export const gatewayConfig = defineConfig({ | ||
supergraph: async (): Promise<string> => { | ||
console.log(`[${new Date().toISOString()}]`, 'Reading ' + SUPERGRAPH_PATH); | ||
return fs.promises.readFile(SUPERGRAPH_PATH, 'utf8'); | ||
}, | ||
pollingInterval: 5_000, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
defineConfig, | ||
loadGraphQLHTTPSubgraph, | ||
} from '@graphql-mesh/compose-cli'; | ||
import { Opts } from '@internal/testing'; | ||
|
||
const opts = Opts(process.argv); | ||
const SERVICE_PORT = opts.getServicePort('Graph'); | ||
|
||
export const composeConfig = defineConfig({ | ||
subgraphs: [ | ||
{ | ||
sourceHandler: loadGraphQLHTTPSubgraph('Graph', { | ||
endpoint: `http://localhost:${SERVICE_PORT}/graphql`, | ||
source: './services/Graph.graphql', | ||
operationHeaders: { | ||
Authorization: "{context.headers['authorization']}", | ||
}, | ||
}), | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@e2e/polling", | ||
"private": true, | ||
"dependencies": { | ||
"@graphql-mesh/compose-cli": "^1.2.13", | ||
"express-graphql": "^0.12.0", | ||
"graphql": "^16.10.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { createTenv } from "@internal/e2e"; | ||
import { describe, expect, it } from "vitest"; | ||
|
||
|
||
describe("Polling", async () => { | ||
const { service, gateway } = createTenv(__dirname); | ||
const gw = await gateway({ | ||
supergraph: { | ||
with: 'mesh', | ||
services: [ | ||
await service('Graph') | ||
] | ||
} | ||
}) | ||
it('should not break the long running query while polling and schema remaining the same', async () => { | ||
const res = await gw.execute({ | ||
query: /* GraphQL */ ` | ||
query { | ||
hello | ||
} | ||
` | ||
}); | ||
expect(res).toMatchObject({ | ||
data: { | ||
hello: 'Hello world!' | ||
} | ||
}); | ||
}, 30_000); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type Query { | ||
hello: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import express from 'express'; | ||
import { graphqlHTTP } from 'express-graphql'; | ||
import { buildSchema } from 'graphql'; | ||
import { Opts } from '@internal/testing'; | ||
|
||
const app = express(); | ||
const opts = Opts(process.argv); | ||
const port = opts.getServicePort('Graph'); | ||
|
||
const schemaPath = path.join(__dirname, 'Graph.graphql'); | ||
const schemaContent = fs.readFileSync(schemaPath, 'utf8'); | ||
|
||
const root = { | ||
hello: () => { | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve('Hello world!'); | ||
}, 20_000); | ||
}); | ||
}, | ||
}; | ||
|
||
app.use( | ||
'/graphql', | ||
graphqlHTTP({ | ||
schema: buildSchema(schemaContent), | ||
rootValue: root, | ||
graphiql: true, | ||
}), | ||
); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is running on http://localhost:${port}/graphql`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters