@constructive-io/graphql-server 4.11.5 → 4.12.0
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/esm/middleware/graphile.js +55 -53
- package/middleware/graphile.js +55 -53
- package/package.json +4 -4
|
@@ -107,62 +107,64 @@ export function clearInFlightMap() {
|
|
|
107
107
|
const log = new Logger('graphile');
|
|
108
108
|
const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
|
|
109
109
|
/**
|
|
110
|
-
* Build a PostGraphile v5 preset for a tenant
|
|
110
|
+
* Build a PostGraphile v5 preset for a tenant.
|
|
111
111
|
*/
|
|
112
|
-
const buildPreset = (connectionString, schemas, anonRole, roleName) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (req
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
112
|
+
const buildPreset = (connectionString, schemas, anonRole, roleName) => {
|
|
113
|
+
return {
|
|
114
|
+
extends: [ConstructivePreset],
|
|
115
|
+
pgServices: [
|
|
116
|
+
makePgService({
|
|
117
|
+
connectionString,
|
|
118
|
+
schemas,
|
|
119
|
+
}),
|
|
120
|
+
],
|
|
121
|
+
grafserv: {
|
|
122
|
+
graphqlPath: '/graphql',
|
|
123
|
+
graphiqlPath: '/graphiql',
|
|
124
|
+
graphiql: true,
|
|
125
|
+
graphiqlOnGraphQLGET: false,
|
|
126
|
+
maskError,
|
|
127
|
+
},
|
|
128
|
+
grafast: {
|
|
129
|
+
explain: process.env.NODE_ENV === 'development',
|
|
130
|
+
context: (requestContext) => {
|
|
131
|
+
// In grafserv/express/v4, the request is available at requestContext.expressv4.req
|
|
132
|
+
const req = requestContext?.expressv4?.req;
|
|
133
|
+
const context = {};
|
|
134
|
+
if (req) {
|
|
135
|
+
if (req.databaseId) {
|
|
136
|
+
context['jwt.claims.database_id'] = req.databaseId;
|
|
137
|
+
}
|
|
138
|
+
if (req.clientIp) {
|
|
139
|
+
context['jwt.claims.ip_address'] = req.clientIp;
|
|
140
|
+
}
|
|
141
|
+
if (req.get('origin')) {
|
|
142
|
+
context['jwt.claims.origin'] = req.get('origin');
|
|
143
|
+
}
|
|
144
|
+
if (req.get('User-Agent')) {
|
|
145
|
+
context['jwt.claims.user_agent'] = req.get('User-Agent');
|
|
146
|
+
}
|
|
147
|
+
if (req.token?.user_id) {
|
|
148
|
+
return {
|
|
149
|
+
pgSettings: {
|
|
150
|
+
role: roleName,
|
|
151
|
+
'jwt.claims.token_id': req.token.id,
|
|
152
|
+
'jwt.claims.user_id': req.token.user_id,
|
|
153
|
+
...context,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
155
157
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
158
|
+
return {
|
|
159
|
+
pgSettings: {
|
|
160
|
+
role: anonRole,
|
|
161
|
+
...context,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
},
|
|
163
165
|
},
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
+
};
|
|
167
|
+
};
|
|
166
168
|
export const graphile = (opts) => {
|
|
167
169
|
const observabilityEnabled = isGraphqlObservabilityEnabled(opts.server?.host);
|
|
168
170
|
return async (req, res, next) => {
|
package/middleware/graphile.js
CHANGED
|
@@ -116,62 +116,64 @@ function clearInFlightMap() {
|
|
|
116
116
|
const log = new logger_1.Logger('graphile');
|
|
117
117
|
const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
|
|
118
118
|
/**
|
|
119
|
-
* Build a PostGraphile v5 preset for a tenant
|
|
119
|
+
* Build a PostGraphile v5 preset for a tenant.
|
|
120
120
|
*/
|
|
121
|
-
const buildPreset = (connectionString, schemas, anonRole, roleName) =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (req
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
121
|
+
const buildPreset = (connectionString, schemas, anonRole, roleName) => {
|
|
122
|
+
return {
|
|
123
|
+
extends: [graphile_settings_1.ConstructivePreset],
|
|
124
|
+
pgServices: [
|
|
125
|
+
(0, graphile_settings_1.makePgService)({
|
|
126
|
+
connectionString,
|
|
127
|
+
schemas,
|
|
128
|
+
}),
|
|
129
|
+
],
|
|
130
|
+
grafserv: {
|
|
131
|
+
graphqlPath: '/graphql',
|
|
132
|
+
graphiqlPath: '/graphiql',
|
|
133
|
+
graphiql: true,
|
|
134
|
+
graphiqlOnGraphQLGET: false,
|
|
135
|
+
maskError,
|
|
136
|
+
},
|
|
137
|
+
grafast: {
|
|
138
|
+
explain: process.env.NODE_ENV === 'development',
|
|
139
|
+
context: (requestContext) => {
|
|
140
|
+
// In grafserv/express/v4, the request is available at requestContext.expressv4.req
|
|
141
|
+
const req = requestContext?.expressv4?.req;
|
|
142
|
+
const context = {};
|
|
143
|
+
if (req) {
|
|
144
|
+
if (req.databaseId) {
|
|
145
|
+
context['jwt.claims.database_id'] = req.databaseId;
|
|
146
|
+
}
|
|
147
|
+
if (req.clientIp) {
|
|
148
|
+
context['jwt.claims.ip_address'] = req.clientIp;
|
|
149
|
+
}
|
|
150
|
+
if (req.get('origin')) {
|
|
151
|
+
context['jwt.claims.origin'] = req.get('origin');
|
|
152
|
+
}
|
|
153
|
+
if (req.get('User-Agent')) {
|
|
154
|
+
context['jwt.claims.user_agent'] = req.get('User-Agent');
|
|
155
|
+
}
|
|
156
|
+
if (req.token?.user_id) {
|
|
157
|
+
return {
|
|
158
|
+
pgSettings: {
|
|
159
|
+
role: roleName,
|
|
160
|
+
'jwt.claims.token_id': req.token.id,
|
|
161
|
+
'jwt.claims.user_id': req.token.user_id,
|
|
162
|
+
...context,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
164
166
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
}
|
|
167
|
+
return {
|
|
168
|
+
pgSettings: {
|
|
169
|
+
role: anonRole,
|
|
170
|
+
...context,
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
},
|
|
172
174
|
},
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
+
};
|
|
176
|
+
};
|
|
175
177
|
const graphile = (opts) => {
|
|
176
178
|
const observabilityEnabled = (0, observability_1.isGraphqlObservabilityEnabled)(opts.server?.host);
|
|
177
179
|
return async (req, res, next) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Constructive GraphQL Server",
|
|
6
6
|
"main": "index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"graphile-build-pg": "5.0.0-rc.8",
|
|
64
64
|
"graphile-cache": "^3.3.4",
|
|
65
65
|
"graphile-config": "1.0.0-rc.6",
|
|
66
|
-
"graphile-settings": "^4.
|
|
66
|
+
"graphile-settings": "^4.11.0",
|
|
67
67
|
"graphile-utils": "5.0.0-rc.8",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"graphql-upload": "^13.0.0",
|
|
@@ -86,10 +86,10 @@
|
|
|
86
86
|
"@types/multer": "^2.1.0",
|
|
87
87
|
"@types/pg": "^8.18.0",
|
|
88
88
|
"@types/request-ip": "^0.0.41",
|
|
89
|
-
"graphile-test": "4.5.
|
|
89
|
+
"graphile-test": "4.5.8",
|
|
90
90
|
"makage": "^0.1.10",
|
|
91
91
|
"nodemon": "^3.1.14",
|
|
92
92
|
"ts-node": "^10.9.2"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "d7ad4d8a95a9ab73c9eee919e0cdfcc2334845af"
|
|
95
95
|
}
|