-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path@subsquid+graphql-server+3.3.2.patch
78 lines (78 loc) · 3.47 KB
/
@subsquid+graphql-server+3.3.2.patch
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
71
72
73
74
75
76
77
78
diff --git a/node_modules/@subsquid/graphql-server/lib/resolvers.js b/node_modules/@subsquid/graphql-server/lib/resolvers.js
index ea605c2..2564ebd 100644
--- a/node_modules/@subsquid/graphql-server/lib/resolvers.js
+++ b/node_modules/@subsquid/graphql-server/lib/resolvers.js
@@ -19,6 +19,7 @@ async function loadCustomResolvers(mod) {
return (0, type_graphql_1.buildSchema)({
resolvers: [mod],
scalarsMap,
+ validate: { forbidUnknownValues: false },
container: resolverData => new CustomResolversContainer(resolverData)
});
}
diff --git a/node_modules/@subsquid/graphql-server/lib/server.js b/node_modules/@subsquid/graphql-server/lib/server.js
index 04e74c3..e95a07b 100644
--- a/node_modules/@subsquid/graphql-server/lib/server.js
+++ b/node_modules/@subsquid/graphql-server/lib/server.js
@@ -90,16 +90,17 @@ class Server {
});
}
async schema() {
- let schemas = [
- new schema_2.SchemaBuilder({ model: this.model(), subscriptions: this.options.subscriptions }).build()
- ];
- if (this.options.squidStatus !== false) {
- schemas.push(this.squidStatusSchema());
- }
let customResolvers = await this.customResolvers();
+ let schemas = []
if (customResolvers) {
schemas.push(customResolvers);
}
+ schemas.push(
+ new schema_2.SchemaBuilder({ model: this.model(), subscriptions: this.options.subscriptions }).build()
+ );
+ if (this.options.squidStatus !== false) {
+ schemas.push(this.squidStatusSchema());
+ }
return (0, schema_1.mergeSchemas)({ schemas });
}
squidStatusSchema() {
@@ -177,7 +178,7 @@ class Server {
return new db_1.PoolOpenreaderContext(dialect, pool, pool, this.options.subscriptionPollInterval);
};
}
- return () => {
+ return ({ req }) => {
let openreader = createOpenreader();
if (this.options.maxResponseNodes) {
openreader.responseSizeLimit = new limit_1.ResponseSizeLimit(this.options.maxResponseNodes);
@@ -186,7 +187,7 @@ class Server {
if (this.options.subscriptionMaxResponseNodes) {
openreader.subscriptionResponseSizeLimit = new limit_1.ResponseSizeLimit(this.options.subscriptionMaxResponseNodes);
}
- return { openreader };
+ return { req, openreader };
};
}
async createTypeormConnection(options) {
diff --git a/node_modules/@subsquid/graphql-server/src/check.ts b/node_modules/@subsquid/graphql-server/src/check.ts
index 51eee8d..683847b 100644
--- a/node_modules/@subsquid/graphql-server/src/check.ts
+++ b/node_modules/@subsquid/graphql-server/src/check.ts
@@ -48,6 +48,15 @@ export function createCheckPlugin(requestCheck: RequestCheckFunction, model: Mod
model
})
if (typeof ok == 'string') {
+ if (ok === 'Unauthorized') {
+ return {
+ errors: [{ message: 'Unauthorized'}],
+ http: {
+ status: 401,
+ headers: new Headers(),
+ },
+ }
+ }
return {errors: [{message: ok}]}
} else if (ok) {
return null