-
Notifications
You must be signed in to change notification settings - Fork 4
/
benchmark.ts
70 lines (58 loc) · 1.55 KB
/
benchmark.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { bench, group, run } from 'mitata';
import { composeServices as apolloComposeServices } from '@apollo/composition';
import { getSubgraphs } from './__tests__/fixtures/huge-schema/index.js';
import { graphql } from './__tests__/shared/utils.js';
import {
assertCompositionSuccess,
composeServices as guildComposeServices,
} from './src/compose.js';
const basicServices = [
{
name: 'products',
typeDefs: graphql`
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])
type Query {
products: [Product!]!
}
type Product @key(fields: "id") {
id: ID!
name: String!
}
`,
},
{
name: 'reviews',
typeDefs: graphql`
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])
type Query {
reviews: [Review!]!
}
type Product @key(fields: "id") {
id: ID!
reviews: [Review!]!
}
type Review @key(fields: "id") {
id: ID!
body: String!
}
`,
},
];
const hugeSchema = await getSubgraphs();
group('basic schema', () => {
bench('apollo', () => {
assertCompositionSuccess(apolloComposeServices(basicServices));
});
bench('guild', () => {
assertCompositionSuccess(guildComposeServices(basicServices));
});
});
group('huge schema', () => {
bench('apollo', () => {
assertCompositionSuccess(apolloComposeServices(hugeSchema));
});
bench('guild', () => {
assertCompositionSuccess(guildComposeServices(hugeSchema));
});
});
await run();