Mirror: The spec-compliant minimum of client-side GraphQL.

Add initial benchmark suite

+69
benchmark/kitchen_sink.graphql
···
···
+
# Copyright (c) 2015-present, Facebook, Inc.
+
#
+
# This source code is licensed under the MIT license found in the
+
# LICENSE file in the root directory of this source tree.
+
+
query queryName($foo: ComplexType, $site: Site = MOBILE) @onQuery {
+
whoever123is: node(id: [123, 456]) {
+
id
+
... on User @onInlineFragment {
+
field2 {
+
id
+
alias: field1(first: 10, after: $foo) @include(if: $foo) {
+
id
+
...frag @onFragmentSpread
+
}
+
}
+
}
+
... @skip(unless: $foo) {
+
id
+
}
+
... {
+
id
+
}
+
}
+
}
+
+
mutation likeStory @onMutation {
+
like(story: 123) @onField {
+
story {
+
id @onField
+
}
+
}
+
}
+
+
subscription StoryLikeSubscription($input: StoryLikeSubscribeInput)
+
@onSubscription {
+
storyLikeSubscribe(input: $input) {
+
story {
+
likers {
+
count
+
}
+
likeSentence {
+
text
+
}
+
}
+
}
+
}
+
+
fragment frag on Friend @onFragmentDefinition {
+
foo(
+
size: $site
+
bar: 12
+
obj: {
+
key: "value"
+
block: """
+
block string uses \"""
+
"""
+
}
+
)
+
}
+
+
query teeny {
+
unnamed(truthy: true, falsey: false, nullish: null)
+
query
+
}
+
+
query tiny {
+
__typename
+
}
+14
benchmark/package.json
···
···
+
{
+
"name": "benchmark",
+
"private": true,
+
"version": "1.0.0",
+
"main": "suite.js",
+
"license": "MIT",
+
"scripts": {
+
"start": "NODE_ENV=production benchr suite.js"
+
},
+
"dependencies": {
+
"benchr": "4.3.0",
+
"graphql": "^16.6.0"
+
}
+
}
+26
benchmark/suite.js
···
···
+
const fs = require('fs');
+
const graphqlWeb = require('..');
+
const graphql = require('graphql');
+
+
const kitchenSink = fs.readFileSync('./kitchen_sink.graphql', { encoding: 'utf8' });
+
const document = graphql.parse(kitchenSink, { noLocation: true });
+
+
suite('parse kitchen sink query', () => {
+
benchmark('0no-co/graphql.web', () => {
+
graphqlWeb.parse(kitchenSink);
+
});
+
+
benchmark('graphql', () => {
+
graphql.parse(kitchenSink, { noLocation: true });
+
});
+
});
+
+
suite('print kitchen sink query', () => {
+
benchmark('0no-co/graphql.web', () => {
+
graphqlWeb.print(document);
+
});
+
+
benchmark('graphql', () => {
+
graphql.print(document);
+
});
+
});
+2
pnpm-workspace.yaml
···
···
+
packages:
+
- 'benchmark'