Skip to content

Commit 4c25a0e

Browse files
committed
add additional benchmark
see #3754 (comment)
1 parent 1bf71ee commit 4c25a0e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { execute } from 'graphql/execution/execute.js';
2+
import { parse } from 'graphql/language/parser.js';
3+
import { buildSchema } from 'graphql/utilities/buildASTSchema.js';
4+
5+
const schema = buildSchema(`
6+
type Query {
7+
listField: [Object]
8+
}
9+
10+
type Object {
11+
field: String
12+
}
13+
`);
14+
const document = parse('{ listField { field } }');
15+
16+
function listField() {
17+
const results = [];
18+
for (let index = 0; index < 1; index++) {
19+
results.push(Promise.resolve({ field: Promise.resolve(index) }));
20+
}
21+
return results;
22+
}
23+
24+
export const benchmark = {
25+
name: 'Execute Asynchronous List Field with Nested Asynchronous Fields',
26+
count: 10,
27+
async measure() {
28+
await execute({
29+
schema,
30+
document,
31+
rootValue: { listField },
32+
});
33+
},
34+
};

0 commit comments

Comments
 (0)