diff --git a/benchmark/fixtures.js b/benchmark/fixtures.js index d057a80526..8f3aa1edd8 100644 --- a/benchmark/fixtures.js +++ b/benchmark/fixtures.js @@ -8,6 +8,11 @@ exports.bigSchemaSDL = fs.readFileSync( 'utf8', ); +exports.bigDocumentSDL = fs.readFileSync( + path.join(__dirname, 'kitchen-sink.graphql'), + 'utf8', +); + exports.bigSchemaIntrospectionResult = JSON.parse( fs.readFileSync(path.join(__dirname, 'github-schema.json'), 'utf8'), ); diff --git a/benchmark/kitchen-sink.graphql b/benchmark/kitchen-sink.graphql new file mode 100644 index 0000000000..8d9c6ab341 --- /dev/null +++ b/benchmark/kitchen-sink.graphql @@ -0,0 +1,65 @@ +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 @onVariableDefinition +) @onSubscription { + storyLikeSubscribe(input: $input) { + story { + likers { + count + } + likeSentence { + text + } + } + } +} + +fragment frag on Friend @onFragmentDefinition { + foo( + size: $size + bar: $b + obj: { + key: "value" + block: """ + block string uses \""" + """ + } + ) +} + +{ + unnamed(truthy: true, falsy: false, nullish: null) + query +} + +query { + __typename +} diff --git a/benchmark/printer-benchmark.js b/benchmark/printer-benchmark.js new file mode 100644 index 0000000000..6227122b89 --- /dev/null +++ b/benchmark/printer-benchmark.js @@ -0,0 +1,16 @@ +'use strict'; + +const { parse } = require('graphql/language/parser.js'); +const { print } = require('graphql/language/printer.js'); + +const { bigDocumentSDL } = require('./fixtures.js'); + +const document = parse(bigDocumentSDL); + +module.exports = { + name: 'Print kitchen sink document', + count: 1000, + measure() { + print(document); + }, +}; diff --git a/src/language/visitor.ts b/src/language/visitor.ts index daf96497bf..b392feeff0 100644 --- a/src/language/visitor.ts +++ b/src/language/visitor.ts @@ -222,10 +222,7 @@ export function visit( } } } else { - node = Object.defineProperties( - {}, - Object.getOwnPropertyDescriptors(node), - ); + node = { ...node }; for (const [editKey, editValue] of edits) { node[editKey] = editValue; }