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

Configure Feed

Select the types of activity you want to include in your feed.

chore: Update benchmarks

+103 -10
+3 -1
benchmark/package.json
··· 9 9 }, 10 10 "dependencies": { 11 11 "benchr": "4.3.0", 12 - "graphql": "^16.6.0" 12 + "graphql15": "npm:graphql@^15.8.0", 13 + "graphql16": "npm:graphql@^16.6.0", 14 + "graphql17": "npm:graphql@^17.0.0-alpha.2" 13 15 } 14 16 }
+84 -7
benchmark/suite.js
··· 1 1 const fs = require('fs'); 2 2 const graphqlWeb = require('..'); 3 - const graphql = require('graphql'); 3 + const graphql15 = require('graphql15'); 4 + const graphql16 = require('graphql16'); 5 + const graphql17 = require('graphql17'); 4 6 5 - const kitchenSink = fs.readFileSync('./kitchen_sink.graphql', { encoding: 'utf8' }); 6 - const document = graphql.parse(kitchenSink, { noLocation: true }); 7 + const kitchenSink = 8 + fs.readFileSync('../src/__tests__/kitchen_sink.graphql', { encoding: 'utf8' }); 9 + const document = require('../src/__tests__/kitchen_sink.json'); 7 10 8 11 suite('parse kitchen sink query', () => { 9 12 benchmark('0no-co/graphql.web', () => { 10 13 graphqlWeb.parse(kitchenSink); 11 14 }); 12 15 13 - benchmark('graphql', () => { 14 - graphql.parse(kitchenSink, { noLocation: true }); 16 + benchmark('graphql@15', () => { 17 + graphql15.parse(kitchenSink, { noLocation: true }); 18 + }); 19 + 20 + benchmark('graphql@16', () => { 21 + graphql16.parse(kitchenSink, { noLocation: true }); 22 + }); 23 + 24 + benchmark('graphql@17', () => { 25 + graphql17.parse(kitchenSink, { noLocation: true }); 15 26 }); 16 27 }); 17 28 ··· 20 31 graphqlWeb.print(document); 21 32 }); 22 33 23 - benchmark('graphql', () => { 24 - graphql.print(document); 34 + benchmark('graphql@15', () => { 35 + graphql15.print(document); 36 + }); 37 + 38 + benchmark('graphql@16', () => { 39 + graphql16.print(document); 40 + }); 41 + 42 + benchmark('graphql@17', () => { 43 + graphql17.print(document); 44 + }); 45 + }); 46 + 47 + suite('visit kitchen sink query', () => { 48 + benchmark('0no-co/graphql.web', () => { 49 + graphqlWeb.visit(document, { 50 + Field: formatNode, 51 + InlineFragment: formatNode, 52 + }); 53 + }); 54 + 55 + benchmark('graphql@15', () => { 56 + graphql15.visit(document, { 57 + Field: formatNode, 58 + InlineFragment: formatNode, 59 + }); 60 + }); 61 + 62 + benchmark('graphql@16', () => { 63 + graphql16.visit(document, { 64 + Field: formatNode, 65 + InlineFragment: formatNode, 66 + }); 67 + }); 68 + 69 + benchmark('graphql@17', () => { 70 + graphql17.visit(document, { 71 + Field: formatNode, 72 + InlineFragment: formatNode, 73 + }); 25 74 }); 26 75 }); 76 + 77 + function formatNode(node) { 78 + if (!node.selectionSet) return node; 79 + for (const selection of node.selectionSet.selections) 80 + if ( 81 + selection.kind === 'Field' && 82 + selection.name.value === '__typename' && 83 + !selection.alias 84 + ) 85 + return node; 86 + 87 + return { 88 + ...node, 89 + selectionSet: { 90 + ...node.selectionSet, 91 + selections: [ 92 + ...node.selectionSet.selections, 93 + { 94 + kind: 'Field', 95 + name: { 96 + kind: 'Name', 97 + value: '__typename', 98 + }, 99 + }, 100 + ], 101 + }, 102 + }; 103 + }
+16 -2
pnpm-lock.yaml
··· 61 61 benchmark: 62 62 specifiers: 63 63 benchr: 4.3.0 64 - graphql: ^16.6.0 64 + graphql15: npm:graphql@^15.8.0 65 + graphql16: npm:graphql@^16.6.0 66 + graphql17: npm:graphql@^17.0.0-alpha.2 65 67 dependencies: 66 68 benchr: 4.3.0 67 - graphql: 16.6.0 69 + graphql15: /graphql/15.8.0 70 + graphql16: /graphql/16.6.0 71 + graphql17: /graphql/17.0.0-alpha.2 68 72 69 73 packages: 70 74 ··· 2116 2120 resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} 2117 2121 dev: true 2118 2122 2123 + /graphql/15.8.0: 2124 + resolution: {integrity: sha512-5gghUc24tP9HRznNpV2+FIoq3xKkj5dTQqf4v0CpdPbFVwFkWoxOM+o+2OC9ZSvjEMTjfmG9QT+gcvggTwW1zw==} 2125 + engines: {node: '>= 10.x'} 2126 + dev: false 2127 + 2119 2128 /graphql/16.6.0: 2120 2129 resolution: {integrity: sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==} 2121 2130 engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} 2131 + 2132 + /graphql/17.0.0-alpha.2: 2133 + resolution: {integrity: sha512-aRAd/BQ5hSO0+l7x+sHBfJVUp2JUOjPTE/iwJ3BhtYNH/MC7n4gjlZbKvnBVFZZAczyMS3vezS4teEZivoqIzw==} 2134 + engines: {node: ^14.19.0 || ^16.10.0 || >=18.0.0} 2135 + dev: false 2122 2136 2123 2137 /hard-rejection/2.1.0: 2124 2138 resolution: {integrity: sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==}