forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow list field resolvers to return async iterables (#38)
* support async benchmark tests * Add benchmarks for sync and async list fields * Support returning async iterables from resolver functions Support returning async iterables from resolver functions * add benchmark tests for async iterable list fields * add changeset Co-authored-by: Rob Richard <rob@1stdibs.com>
- Loading branch information
1 parent
8ad6a6c
commit 8df89b5
Showing
4 changed files
with
271 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,7 @@ | ||
--- | ||
'graphql-executor': patch | ||
--- | ||
|
||
Allow list field resolvers to return async iterables | ||
|
||
https://github.com/graphql/graphql-js/pull/2757 |
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,26 @@ | ||
'use strict'; | ||
|
||
const { parse } = require('graphql/language/parser.js'); | ||
const { execute } = require('graphql/execution/execute.js'); | ||
const { buildSchema } = require('graphql/utilities/buildASTSchema.js'); | ||
|
||
const schema = buildSchema('type Query { listField: [String] }'); | ||
const document = parse('{ listField }'); | ||
|
||
async function* listField() { | ||
for (let index = 0; index < 100000; index++) { | ||
yield index; | ||
} | ||
} | ||
|
||
module.exports = { | ||
name: 'Execute Async Iterable List Field', | ||
count: 10, | ||
async measure() { | ||
await execute({ | ||
schema, | ||
document, | ||
rootValue: { listField }, | ||
}); | ||
}, | ||
}; |
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