-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(json-schema/oas/raml):
timeout
option
- Loading branch information
Showing
13 changed files
with
110 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,9 @@ | ||
--- | ||
'@graphql-mesh/json-schema': minor | ||
'@omnigraph/json-schema': minor | ||
'@graphql-mesh/openapi': minor | ||
'@graphql-mesh/raml': minor | ||
'@graphql-mesh/types': patch | ||
--- | ||
|
||
`timeout` option for HTTP requests |
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
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
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
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
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
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
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
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,49 @@ | ||
/* eslint-disable import/no-nodejs-modules */ | ||
import { createServer, Server } from 'http'; | ||
import { AddressInfo } from 'net'; | ||
import { execute, OperationTypeNode, parse } from 'graphql'; | ||
import { fetch } from '@whatwg-node/fetch'; | ||
import { loadGraphQLSchemaFromJSONSchemas } from '../src/loadGraphQLSchemaFromJSONSchemas'; | ||
|
||
describe('Timeout', () => { | ||
let server: Server; | ||
beforeAll(async () => { | ||
server = createServer((req, res) => { | ||
setTimeout(() => { | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end('test'); | ||
}, 500); | ||
}); | ||
await new Promise<void>(resolve => server.listen(0, resolve)); | ||
}); | ||
afterAll(async () => { | ||
await new Promise(resolve => server.close(resolve)); | ||
}); | ||
it('should timeout correctly', async () => { | ||
const schema = await loadGraphQLSchemaFromJSONSchemas('test', { | ||
fetch, | ||
timeout: 300, | ||
endpoint: `http://localhost:${(server.address() as AddressInfo).port}`, | ||
operations: [ | ||
{ | ||
type: OperationTypeNode.QUERY, | ||
field: 'test', | ||
method: 'GET', | ||
path: '/test', | ||
responseSchema: { | ||
type: 'object', | ||
}, | ||
}, | ||
], | ||
}); | ||
const result = await execute({ | ||
schema, | ||
document: parse(/* GraphQL */ ` | ||
query { | ||
test | ||
} | ||
`), | ||
}); | ||
expect(result?.errors?.[0]?.message).toContain('timeout in 300 ms'); | ||
}); | ||
}); |
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
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
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
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