@apollo/federation-internals 2.4.4 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Subgraph.d.ts +1 -0
- package/dist/Subgraph.d.ts.map +1 -0
- package/dist/Subgraph.js +2 -0
- package/dist/Subgraph.js.map +1 -0
- package/dist/argumentCompositionStrategies.d.ts +34 -0
- package/dist/argumentCompositionStrategies.d.ts.map +1 -0
- package/dist/argumentCompositionStrategies.js +35 -0
- package/dist/argumentCompositionStrategies.js.map +1 -0
- package/dist/buildSchema.d.ts +10 -0
- package/dist/buildSchema.d.ts.map +1 -0
- package/dist/buildSchema.js +362 -0
- package/dist/buildSchema.js.map +1 -0
- package/dist/coreSpec.d.ts +127 -0
- package/dist/coreSpec.d.ts.map +1 -0
- package/dist/coreSpec.js +590 -0
- package/dist/coreSpec.js.map +1 -0
- package/dist/debug.d.ts +15 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +122 -0
- package/dist/debug.js.map +1 -0
- package/dist/definitions.d.ts +663 -0
- package/dist/definitions.d.ts.map +1 -0
- package/dist/definitions.js +2841 -0
- package/dist/definitions.js.map +1 -0
- package/dist/directiveAndTypeSpecification.d.ts +67 -0
- package/dist/directiveAndTypeSpecification.d.ts.map +1 -0
- package/dist/directiveAndTypeSpecification.js +271 -0
- package/dist/directiveAndTypeSpecification.js.map +1 -0
- package/dist/error.d.ts +128 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +315 -0
- package/dist/error.js.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts +8 -0
- package/dist/extractSubgraphsFromSupergraph.d.ts.map +1 -0
- package/dist/extractSubgraphsFromSupergraph.js +576 -0
- package/dist/extractSubgraphsFromSupergraph.js.map +1 -0
- package/dist/federation.d.ts +175 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +1414 -0
- package/dist/federation.js.map +1 -0
- package/dist/federationSpec.d.ts +25 -0
- package/dist/federationSpec.d.ts.map +1 -0
- package/dist/federationSpec.js +125 -0
- package/dist/federationSpec.js.map +1 -0
- package/dist/genErrorCodeDoc.d.ts +2 -0
- package/dist/genErrorCodeDoc.d.ts.map +1 -0
- package/dist/genErrorCodeDoc.js +61 -0
- package/dist/genErrorCodeDoc.js.map +1 -0
- package/dist/graphQLJSSchemaToAST.d.ts +8 -0
- package/dist/graphQLJSSchemaToAST.d.ts.map +1 -0
- package/dist/graphQLJSSchemaToAST.js +96 -0
- package/dist/graphQLJSSchemaToAST.js.map +1 -0
- package/dist/inaccessibleSpec.d.ts +18 -0
- package/dist/inaccessibleSpec.d.ts.map +1 -0
- package/dist/inaccessibleSpec.js +655 -0
- package/dist/inaccessibleSpec.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/introspection.d.ts +6 -0
- package/dist/introspection.d.ts.map +1 -0
- package/dist/introspection.js +96 -0
- package/dist/introspection.js.map +1 -0
- package/dist/joinSpec.d.ts +51 -0
- package/dist/joinSpec.d.ts.map +1 -0
- package/dist/joinSpec.js +160 -0
- package/dist/joinSpec.js.map +1 -0
- package/dist/knownCoreFeatures.d.ts +5 -0
- package/dist/knownCoreFeatures.d.ts.map +1 -0
- package/dist/knownCoreFeatures.js +20 -0
- package/dist/knownCoreFeatures.js.map +1 -0
- package/dist/operations.d.ts +418 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +2068 -0
- package/dist/operations.js.map +1 -0
- package/dist/precompute.d.ts +3 -0
- package/dist/precompute.d.ts.map +1 -0
- package/dist/precompute.js +54 -0
- package/dist/precompute.js.map +1 -0
- package/dist/print.d.ts +28 -0
- package/dist/print.d.ts.map +1 -0
- package/dist/print.js +299 -0
- package/dist/print.js.map +1 -0
- package/dist/schemaUpgrader.d.ts +121 -0
- package/dist/schemaUpgrader.d.ts.map +1 -0
- package/dist/schemaUpgrader.js +570 -0
- package/dist/schemaUpgrader.js.map +1 -0
- package/dist/suggestions.d.ts +3 -0
- package/dist/suggestions.d.ts.map +1 -0
- package/dist/suggestions.js +44 -0
- package/dist/suggestions.js.map +1 -0
- package/dist/supergraphs.d.ts +10 -0
- package/dist/supergraphs.d.ts.map +1 -0
- package/dist/supergraphs.js +76 -0
- package/dist/supergraphs.js.map +1 -0
- package/dist/tagSpec.d.ts +19 -0
- package/dist/tagSpec.d.ts.map +1 -0
- package/dist/tagSpec.js +66 -0
- package/dist/tagSpec.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +64 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +64 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +326 -0
- package/dist/utils.js.map +1 -0
- package/dist/validate.d.ts +4 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +239 -0
- package/dist/validate.js.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts +4 -0
- package/dist/validation/KnownTypeNamesInFederationRule.d.ts.map +1 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js +41 -0
- package/dist/validation/KnownTypeNamesInFederationRule.js.map +1 -0
- package/dist/values.d.ts +23 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +580 -0
- package/dist/values.js.map +1 -0
- package/package.json +1 -1
- package/src/operations.ts +145 -20
- package/src/utils.ts +1 -1
- package/CHANGELOG.md +0 -205
- package/jest.config.js +0 -11
- package/src/__tests__/coreSpec.test.ts +0 -212
- package/src/__tests__/definitions.test.ts +0 -982
- package/src/__tests__/directiveAndTypeSpecifications.test.ts +0 -41
- package/src/__tests__/extractSubgraphsFromSupergraph.test.ts +0 -748
- package/src/__tests__/federation.test.ts +0 -31
- package/src/__tests__/graphQLJSSchemaToAST.test.ts +0 -156
- package/src/__tests__/matchers/index.ts +0 -1
- package/src/__tests__/matchers/toMatchString.ts +0 -87
- package/src/__tests__/operations.test.ts +0 -1266
- package/src/__tests__/removeInaccessibleElements.test.ts +0 -2471
- package/src/__tests__/schemaUpgrader.test.ts +0 -287
- package/src/__tests__/subgraphValidation.test.ts +0 -1254
- package/src/__tests__/supergraphSdl.graphql +0 -281
- package/src/__tests__/testUtils.ts +0 -28
- package/src/__tests__/toAPISchema.test.ts +0 -53
- package/src/__tests__/tsconfig.json +0 -7
- package/src/__tests__/utils.test.ts +0 -92
- package/src/__tests__/values.test.ts +0 -390
- package/tsconfig.json +0 -10
- package/tsconfig.test.json +0 -8
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
schema
|
|
2
|
-
@core(feature: "https://specs.apollo.dev/core/v0.2"),
|
|
3
|
-
@core(feature: "https://specs.apollo.dev/join/v0.1", for: EXECUTION)
|
|
4
|
-
{
|
|
5
|
-
query: Query
|
|
6
|
-
mutation: Mutation
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
directive @core(feature: String!, as: String, for: core__Purpose) repeatable on SCHEMA
|
|
10
|
-
|
|
11
|
-
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet) on FIELD_DEFINITION
|
|
12
|
-
|
|
13
|
-
directive @join__type(graph: join__Graph!, key: join__FieldSet) repeatable on OBJECT | INTERFACE
|
|
14
|
-
|
|
15
|
-
directive @join__owner(graph: join__Graph!) on OBJECT | INTERFACE
|
|
16
|
-
|
|
17
|
-
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
|
|
18
|
-
|
|
19
|
-
directive @stream on FIELD
|
|
20
|
-
|
|
21
|
-
directive @fragmentDirective on INLINE_FRAGMENT
|
|
22
|
-
|
|
23
|
-
directive @transform(from: String!) on FIELD
|
|
24
|
-
|
|
25
|
-
type Account {
|
|
26
|
-
type: String
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
union AccountType = PasswordAccount | SMSAccount
|
|
30
|
-
|
|
31
|
-
type Amazon {
|
|
32
|
-
referrer: String
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
union Body = Image | Text
|
|
36
|
-
|
|
37
|
-
type Book implements Product
|
|
38
|
-
@join__owner(graph: BOOKS)
|
|
39
|
-
@join__type(graph: BOOKS, key: "isbn")
|
|
40
|
-
@join__type(graph: INVENTORY, key: "isbn")
|
|
41
|
-
@join__type(graph: PRODUCT, key: "isbn")
|
|
42
|
-
@join__type(graph: REVIEWS, key: "isbn")
|
|
43
|
-
{
|
|
44
|
-
isbn: String! @join__field(graph: BOOKS)
|
|
45
|
-
title: String @join__field(graph: BOOKS)
|
|
46
|
-
year: Int @join__field(graph: BOOKS)
|
|
47
|
-
similarBooks: [Book]! @join__field(graph: BOOKS)
|
|
48
|
-
metadata: [MetadataOrError] @join__field(graph: BOOKS)
|
|
49
|
-
inStock: Boolean @join__field(graph: INVENTORY)
|
|
50
|
-
isCheckedOut: Boolean @join__field(graph: INVENTORY)
|
|
51
|
-
upc: String! @join__field(graph: PRODUCT)
|
|
52
|
-
sku: String! @join__field(graph: PRODUCT)
|
|
53
|
-
name(delimeter: String = " "): String @join__field(graph: PRODUCT, requires: "title year")
|
|
54
|
-
price: String @join__field(graph: PRODUCT)
|
|
55
|
-
details: ProductDetailsBook @join__field(graph: PRODUCT)
|
|
56
|
-
reviews: [Review] @join__field(graph: REVIEWS)
|
|
57
|
-
relatedReviews: [Review!]! @join__field(graph: REVIEWS, requires: "similarBooks { isbn }")
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
union Brand = Ikea | Amazon
|
|
61
|
-
|
|
62
|
-
type Car implements Vehicle
|
|
63
|
-
@join__owner(graph: PRODUCT)
|
|
64
|
-
@join__type(graph: PRODUCT, key: "id")
|
|
65
|
-
@join__type(graph: REVIEWS, key: "id")
|
|
66
|
-
{
|
|
67
|
-
id: String! @join__field(graph: PRODUCT)
|
|
68
|
-
description: String @join__field(graph: PRODUCT)
|
|
69
|
-
price: String @join__field(graph: PRODUCT)
|
|
70
|
-
retailPrice: String @join__field(graph: REVIEWS, requires: "price")
|
|
71
|
-
thing: Thing
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
enum core__Purpose {
|
|
75
|
-
EXECUTION
|
|
76
|
-
SECURITY
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
type Error {
|
|
80
|
-
code: Int
|
|
81
|
-
message: String
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
type Furniture implements Product
|
|
85
|
-
@join__owner(graph: PRODUCT)
|
|
86
|
-
@join__type(graph: PRODUCT, key: "upc")
|
|
87
|
-
@join__type(graph: PRODUCT, key: "sku")
|
|
88
|
-
@join__type(graph: INVENTORY, key: "sku")
|
|
89
|
-
@join__type(graph: REVIEWS, key: "upc")
|
|
90
|
-
{
|
|
91
|
-
upc: String! @join__field(graph: PRODUCT)
|
|
92
|
-
sku: String! @join__field(graph: PRODUCT)
|
|
93
|
-
name: String @join__field(graph: PRODUCT)
|
|
94
|
-
price: String @join__field(graph: PRODUCT)
|
|
95
|
-
brand: Brand @join__field(graph: PRODUCT)
|
|
96
|
-
metadata: [MetadataOrError] @join__field(graph: PRODUCT)
|
|
97
|
-
details: ProductDetailsFurniture @join__field(graph: PRODUCT)
|
|
98
|
-
inStock: Boolean @join__field(graph: INVENTORY)
|
|
99
|
-
isHeavy: Boolean @join__field(graph: INVENTORY)
|
|
100
|
-
reviews: [Review] @join__field(graph: REVIEWS)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
type Ikea {
|
|
104
|
-
asile: Int
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
type Image {
|
|
108
|
-
name: String!
|
|
109
|
-
attributes: ImageAttributes!
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
type ImageAttributes {
|
|
113
|
-
url: String!
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
scalar join__FieldSet
|
|
117
|
-
|
|
118
|
-
enum join__Graph {
|
|
119
|
-
ACCOUNTS @join__graph(name: "accounts" url: "undefined")
|
|
120
|
-
BOOKS @join__graph(name: "books" url: "undefined")
|
|
121
|
-
DOCUMENTS @join__graph(name: "documents" url: "undefined")
|
|
122
|
-
INVENTORY @join__graph(name: "inventory" url: "undefined")
|
|
123
|
-
PRODUCT @join__graph(name: "product" url: "undefined")
|
|
124
|
-
REVIEWS @join__graph(name: "reviews" url: "undefined")
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
type KeyValue {
|
|
128
|
-
key: String!
|
|
129
|
-
value: String!
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
type Library
|
|
133
|
-
@join__owner(graph: BOOKS)
|
|
134
|
-
@join__type(graph: BOOKS, key: "id")
|
|
135
|
-
@join__type(graph: ACCOUNTS, key: "id")
|
|
136
|
-
{
|
|
137
|
-
id: ID! @join__field(graph: BOOKS)
|
|
138
|
-
name: String @join__field(graph: BOOKS)
|
|
139
|
-
userAccount(id: ID! = 1): User @join__field(graph: ACCOUNTS, requires: "name")
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
union MetadataOrError = KeyValue | Error
|
|
143
|
-
|
|
144
|
-
type Mutation {
|
|
145
|
-
login(username: String!, password: String!): User @join__field(graph: ACCOUNTS)
|
|
146
|
-
reviewProduct(upc: String!, body: String!): Product @join__field(graph: REVIEWS)
|
|
147
|
-
updateReview(review: UpdateReviewInput!): Review @join__field(graph: REVIEWS)
|
|
148
|
-
deleteReview(id: ID!): Boolean @join__field(graph: REVIEWS)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
type Name {
|
|
152
|
-
first: String
|
|
153
|
-
last: String
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
type PasswordAccount
|
|
157
|
-
@join__owner(graph: ACCOUNTS)
|
|
158
|
-
@join__type(graph: ACCOUNTS, key: "email")
|
|
159
|
-
{
|
|
160
|
-
email: String! @join__field(graph: ACCOUNTS)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
interface Product {
|
|
164
|
-
upc: String!
|
|
165
|
-
sku: String!
|
|
166
|
-
name: String
|
|
167
|
-
price: String
|
|
168
|
-
details: ProductDetails
|
|
169
|
-
inStock: Boolean
|
|
170
|
-
reviews: [Review]
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
interface ProductDetails {
|
|
174
|
-
country: String
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
type ProductDetailsBook implements ProductDetails {
|
|
178
|
-
country: String
|
|
179
|
-
pages: Int
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
type ProductDetailsFurniture implements ProductDetails {
|
|
183
|
-
country: String
|
|
184
|
-
color: String
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
type Query {
|
|
188
|
-
user(id: ID!): User @join__field(graph: ACCOUNTS)
|
|
189
|
-
me: User @join__field(graph: ACCOUNTS)
|
|
190
|
-
book(isbn: String!): Book @join__field(graph: BOOKS)
|
|
191
|
-
books: [Book] @join__field(graph: BOOKS)
|
|
192
|
-
library(id: ID!): Library @join__field(graph: BOOKS)
|
|
193
|
-
body: Body! @join__field(graph: DOCUMENTS)
|
|
194
|
-
product(upc: String!): Product @join__field(graph: PRODUCT)
|
|
195
|
-
vehicle(id: String!): Vehicle @join__field(graph: PRODUCT)
|
|
196
|
-
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCT)
|
|
197
|
-
topCars(first: Int = 5): [Car] @join__field(graph: PRODUCT)
|
|
198
|
-
topReviews(first: Int = 5): [Review] @join__field(graph: REVIEWS)
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
type Review
|
|
202
|
-
@join__owner(graph: REVIEWS)
|
|
203
|
-
@join__type(graph: REVIEWS, key: "id")
|
|
204
|
-
{
|
|
205
|
-
id: ID! @join__field(graph: REVIEWS)
|
|
206
|
-
body(format: Boolean = false): String @join__field(graph: REVIEWS)
|
|
207
|
-
author: User @join__field(graph: REVIEWS, provides: "username")
|
|
208
|
-
product: Product @join__field(graph: REVIEWS)
|
|
209
|
-
metadata: [MetadataOrError] @join__field(graph: REVIEWS)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
type SMSAccount
|
|
213
|
-
@join__owner(graph: ACCOUNTS)
|
|
214
|
-
@join__type(graph: ACCOUNTS, key: "number")
|
|
215
|
-
{
|
|
216
|
-
number: String @join__field(graph: ACCOUNTS)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
type Text {
|
|
220
|
-
name: String!
|
|
221
|
-
attributes: TextAttributes!
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
type TextAttributes {
|
|
225
|
-
bold: Boolean
|
|
226
|
-
text: String
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
union Thing = Car | Ikea
|
|
230
|
-
|
|
231
|
-
input UpdateReviewInput {
|
|
232
|
-
id: ID!
|
|
233
|
-
body: String
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
type User
|
|
237
|
-
@join__owner(graph: ACCOUNTS)
|
|
238
|
-
@join__type(graph: ACCOUNTS, key: "id")
|
|
239
|
-
@join__type(graph: ACCOUNTS, key: "username name { first last }")
|
|
240
|
-
@join__type(graph: INVENTORY, key: "id")
|
|
241
|
-
@join__type(graph: PRODUCT, key: "id")
|
|
242
|
-
@join__type(graph: REVIEWS, key: "id")
|
|
243
|
-
{
|
|
244
|
-
id: ID! @join__field(graph: ACCOUNTS)
|
|
245
|
-
name: Name @join__field(graph: ACCOUNTS)
|
|
246
|
-
username: String @join__field(graph: ACCOUNTS)
|
|
247
|
-
birthDate(locale: String): String @join__field(graph: ACCOUNTS)
|
|
248
|
-
account: Account @join__field(graph: ACCOUNTS)
|
|
249
|
-
accountType: AccountType @join__field(graph: ACCOUNTS)
|
|
250
|
-
metadata: [UserMetadata] @join__field(graph: ACCOUNTS)
|
|
251
|
-
goodDescription: Boolean @join__field(graph: INVENTORY, requires: "metadata { description }")
|
|
252
|
-
vehicle: Vehicle @join__field(graph: PRODUCT)
|
|
253
|
-
thing: Thing @join__field(graph: PRODUCT)
|
|
254
|
-
reviews: [Review] @join__field(graph: REVIEWS)
|
|
255
|
-
numberOfReviews: Int! @join__field(graph: REVIEWS)
|
|
256
|
-
goodAddress: Boolean @join__field(graph: REVIEWS, requires: "metadata { address }")
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
type UserMetadata {
|
|
260
|
-
name: String
|
|
261
|
-
address: String
|
|
262
|
-
description: String
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
type Van implements Vehicle
|
|
266
|
-
@join__owner(graph: PRODUCT)
|
|
267
|
-
@join__type(graph: PRODUCT, key: "id")
|
|
268
|
-
@join__type(graph: REVIEWS, key: "id")
|
|
269
|
-
{
|
|
270
|
-
id: String! @join__field(graph: PRODUCT)
|
|
271
|
-
description: String @join__field(graph: PRODUCT)
|
|
272
|
-
price: String @join__field(graph: PRODUCT)
|
|
273
|
-
retailPrice: String @join__field(graph: REVIEWS, requires: "price")
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
interface Vehicle {
|
|
277
|
-
id: String!
|
|
278
|
-
description: String
|
|
279
|
-
price: String
|
|
280
|
-
retailPrice: String
|
|
281
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { DocumentNode } from "graphql";
|
|
2
|
-
import { asFed2SubgraphDocument, buildSubgraph, errorCauses } from "..";
|
|
3
|
-
import './matchers';
|
|
4
|
-
|
|
5
|
-
// Builds the provided subgraph (using name 'S' for the subgraph) and, if the
|
|
6
|
-
// subgraph is invalid/has errors, return those errors as a list of [code, message].
|
|
7
|
-
// If the subgraph is valid, return undefined.
|
|
8
|
-
export function buildForErrors(
|
|
9
|
-
subgraphDefs: DocumentNode,
|
|
10
|
-
options?: {
|
|
11
|
-
subgraphName?: string,
|
|
12
|
-
asFed2?: boolean,
|
|
13
|
-
}
|
|
14
|
-
): [string, string][] | undefined {
|
|
15
|
-
try {
|
|
16
|
-
const doc = (options?.asFed2 ?? true) ? asFed2SubgraphDocument(subgraphDefs) : subgraphDefs;
|
|
17
|
-
const name = options?.subgraphName ?? 'S';
|
|
18
|
-
buildSubgraph(name, `http://${name}`, doc).validate();
|
|
19
|
-
return undefined;
|
|
20
|
-
} catch (e) {
|
|
21
|
-
const causes = errorCauses(e);
|
|
22
|
-
if (!causes) {
|
|
23
|
-
throw e;
|
|
24
|
-
}
|
|
25
|
-
return causes.map((err) => [err.extensions.code as string, err.message]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { Schema } from '../definitions';
|
|
3
|
-
import { buildSchema } from '../buildSchema';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
function directiveNames(schema: Schema): string[] {
|
|
7
|
-
return [...schema.allDirectives()].map((directive) => directive.name);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function typeNames(schema: Schema): string[] {
|
|
11
|
-
return [...schema.allTypes()].map((type) => type.name);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
describe('toAPISchema', () => {
|
|
15
|
-
let schema: Schema;
|
|
16
|
-
|
|
17
|
-
beforeAll(() => {
|
|
18
|
-
const schemaPath = path.join(
|
|
19
|
-
__dirname,
|
|
20
|
-
'supergraphSdl.graphql',
|
|
21
|
-
);
|
|
22
|
-
const supergraphSdl = fs.readFileSync(schemaPath, 'utf8');
|
|
23
|
-
|
|
24
|
-
schema = buildSchema(supergraphSdl).toAPISchema();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it(`doesn't include core directives`, () => {
|
|
28
|
-
expect(directiveNames(schema)).toEqual(expect.not.arrayContaining(['core']));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it(`doesn't include join directives`, () => {
|
|
32
|
-
expect(directiveNames(schema)).toEqual(
|
|
33
|
-
expect.not.arrayContaining([
|
|
34
|
-
'join__graph',
|
|
35
|
-
'join__type',
|
|
36
|
-
'join__owner',
|
|
37
|
-
'join__field',
|
|
38
|
-
]),
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it(`doesn't include join types`, () => {
|
|
43
|
-
expect(typeNames(schema)).toEqual(
|
|
44
|
-
expect.not.arrayContaining(['join__FieldSet', 'join__Graph']),
|
|
45
|
-
);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it(`does pass through other custom directives`, () => {
|
|
49
|
-
expect(directiveNames(schema)).toEqual(
|
|
50
|
-
expect.arrayContaining([ 'transform', 'stream' ]),
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { OrderedMap } from '../utils';
|
|
2
|
-
|
|
3
|
-
describe('OrderedMap', () => {
|
|
4
|
-
it('updating value works', () => {
|
|
5
|
-
const orderedMap = new OrderedMap<string, number>();
|
|
6
|
-
orderedMap.add('one', 0);
|
|
7
|
-
expect(orderedMap.get('one')).toBe(0);
|
|
8
|
-
expect(orderedMap.size).toBe(1);
|
|
9
|
-
|
|
10
|
-
orderedMap.add('one', 1);
|
|
11
|
-
expect(orderedMap.get('one')).toBe(1);
|
|
12
|
-
expect(orderedMap.size).toBe(1);
|
|
13
|
-
expect(orderedMap.keys()).toEqual(['one']);
|
|
14
|
-
expect(orderedMap.values()).toEqual([1]);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('test lexicographical sorting of map (default sorting algorithm)', () => {
|
|
18
|
-
const orderedMap = new OrderedMap<string, number>();
|
|
19
|
-
orderedMap.add('one', 1);
|
|
20
|
-
orderedMap.add('two', 2);
|
|
21
|
-
orderedMap.add('three', 3);
|
|
22
|
-
orderedMap.add('four', 4);
|
|
23
|
-
orderedMap.add('five', 5);
|
|
24
|
-
orderedMap.add('six', 6);
|
|
25
|
-
orderedMap.add('seven', 7);
|
|
26
|
-
orderedMap.add('eight', 8);
|
|
27
|
-
orderedMap.add('nine', 9);
|
|
28
|
-
|
|
29
|
-
// keys are in alphabetical order
|
|
30
|
-
expect(orderedMap.keys()).toEqual(['eight', 'five', 'four', 'nine', 'one', 'seven', 'six', 'three', 'two']);
|
|
31
|
-
const sortedArr = [8,5,4,9,1,7,6,3,2];
|
|
32
|
-
expect(orderedMap.values()).toEqual(sortedArr);
|
|
33
|
-
|
|
34
|
-
// test using spread operator to make sure iterator is performing correctly
|
|
35
|
-
expect([...orderedMap]).toEqual(sortedArr);
|
|
36
|
-
|
|
37
|
-
// testing get function
|
|
38
|
-
expect(orderedMap.get('one')).toBe(1);
|
|
39
|
-
expect(orderedMap.get('ten')).toBeUndefined();
|
|
40
|
-
|
|
41
|
-
// testing size function
|
|
42
|
-
expect(orderedMap.size).toBe(9);
|
|
43
|
-
orderedMap.add('one', 1);
|
|
44
|
-
expect(orderedMap.size).toBe(9);
|
|
45
|
-
expect(orderedMap.values()).toEqual(sortedArr);
|
|
46
|
-
|
|
47
|
-
// has function
|
|
48
|
-
expect(orderedMap.has('one')).toBe(true);
|
|
49
|
-
expect(orderedMap.has('fifty')).toBe(false);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('sort by string length', () => {
|
|
53
|
-
const orderedMap = new OrderedMap<string, number>((a: string, b: string) => {
|
|
54
|
-
if (a.length < b.length) {
|
|
55
|
-
return -1;
|
|
56
|
-
} else if (b.length < a.length) {
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
return 0;
|
|
60
|
-
});
|
|
61
|
-
orderedMap.add('eight', 8);
|
|
62
|
-
orderedMap.add('seventy', 70);
|
|
63
|
-
orderedMap.add('six', 6);
|
|
64
|
-
orderedMap.add('four', 4);
|
|
65
|
-
|
|
66
|
-
expect(orderedMap.keys()).toEqual(['six', 'four', 'eight', 'seventy']);
|
|
67
|
-
const sortedArr = [6,4,8,70];
|
|
68
|
-
expect(orderedMap.values()).toEqual(sortedArr);
|
|
69
|
-
|
|
70
|
-
// test using spread operator to make sure iterator is performing correctly
|
|
71
|
-
expect([...orderedMap]).toEqual(sortedArr);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('sort numerically', () => {
|
|
75
|
-
const orderedMap = new OrderedMap<number, number>();
|
|
76
|
-
orderedMap.add(4, 40);
|
|
77
|
-
orderedMap.add(1, 10);
|
|
78
|
-
orderedMap.add(7, 70);
|
|
79
|
-
orderedMap.add(2, 20);
|
|
80
|
-
orderedMap.add(6, 60);
|
|
81
|
-
orderedMap.add(3, 30);
|
|
82
|
-
orderedMap.add(9, 90);
|
|
83
|
-
orderedMap.add(5, 50);
|
|
84
|
-
orderedMap.add(8, 80);
|
|
85
|
-
|
|
86
|
-
const keys = [1,2,3,4,5,6,7,8,9];
|
|
87
|
-
const values = [10,20,30,40,50,60,70,80,90];
|
|
88
|
-
expect(orderedMap.keys()).toEqual(keys);
|
|
89
|
-
expect(orderedMap.values()).toEqual(values);
|
|
90
|
-
expect([...orderedMap]).toEqual(values);
|
|
91
|
-
});
|
|
92
|
-
});
|