File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 fieldCount = 1000 ;
6+ const fieldNames = Array . from (
7+ { length : fieldCount } ,
8+ ( _ , index ) => `f${ index } ` ,
9+ ) ;
10+
11+ const schema = buildSchema (
12+ `type Query { ${ fieldNames . map ( ( fieldName ) => `${ fieldName } : Int` ) . join ( ' ' ) } }` ,
13+ ) ;
14+
15+ const document = parse ( `{ ${ fieldNames . join ( ' ' ) } }` ) ;
16+
17+ const rootValue = Object . fromEntries (
18+ fieldNames . map ( ( fieldName , index ) => [
19+ fieldName ,
20+ ( ) => Promise . resolve ( index ) ,
21+ ] ) ,
22+ ) ;
23+
24+ export const benchmark = {
25+ name : 'Execute Asynchronous Fields' ,
26+ measure : ( ) =>
27+ execute ( {
28+ schema,
29+ document,
30+ rootValue,
31+ } ) ,
32+ } ;
You can’t perform that action at this time.
0 commit comments