@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.
@@ -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
- extends: [ConstructivePreset],
114
- pgServices: [
115
- makePgService({
116
- connectionString,
117
- schemas,
118
- }),
119
- ],
120
- grafserv: {
121
- graphqlPath: '/graphql',
122
- graphiqlPath: '/graphiql',
123
- graphiql: true,
124
- graphiqlOnGraphQLGET: false,
125
- maskError,
126
- },
127
- grafast: {
128
- explain: process.env.NODE_ENV === 'development',
129
- context: (requestContext) => {
130
- // In grafserv/express/v4, the request is available at requestContext.expressv4.req
131
- const req = requestContext?.expressv4?.req;
132
- const context = {};
133
- if (req) {
134
- if (req.databaseId) {
135
- context['jwt.claims.database_id'] = req.databaseId;
136
- }
137
- if (req.clientIp) {
138
- context['jwt.claims.ip_address'] = req.clientIp;
139
- }
140
- if (req.get('origin')) {
141
- context['jwt.claims.origin'] = req.get('origin');
142
- }
143
- if (req.get('User-Agent')) {
144
- context['jwt.claims.user_agent'] = req.get('User-Agent');
145
- }
146
- if (req.token?.user_id) {
147
- return {
148
- pgSettings: {
149
- role: roleName,
150
- 'jwt.claims.token_id': req.token.id,
151
- 'jwt.claims.user_id': req.token.user_id,
152
- ...context,
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
- return {
158
- pgSettings: {
159
- role: anonRole,
160
- ...context,
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) => {
@@ -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
- extends: [graphile_settings_1.ConstructivePreset],
123
- pgServices: [
124
- (0, graphile_settings_1.makePgService)({
125
- connectionString,
126
- schemas,
127
- }),
128
- ],
129
- grafserv: {
130
- graphqlPath: '/graphql',
131
- graphiqlPath: '/graphiql',
132
- graphiql: true,
133
- graphiqlOnGraphQLGET: false,
134
- maskError,
135
- },
136
- grafast: {
137
- explain: process.env.NODE_ENV === 'development',
138
- context: (requestContext) => {
139
- // In grafserv/express/v4, the request is available at requestContext.expressv4.req
140
- const req = requestContext?.expressv4?.req;
141
- const context = {};
142
- if (req) {
143
- if (req.databaseId) {
144
- context['jwt.claims.database_id'] = req.databaseId;
145
- }
146
- if (req.clientIp) {
147
- context['jwt.claims.ip_address'] = req.clientIp;
148
- }
149
- if (req.get('origin')) {
150
- context['jwt.claims.origin'] = req.get('origin');
151
- }
152
- if (req.get('User-Agent')) {
153
- context['jwt.claims.user_agent'] = req.get('User-Agent');
154
- }
155
- if (req.token?.user_id) {
156
- return {
157
- pgSettings: {
158
- role: roleName,
159
- 'jwt.claims.token_id': req.token.id,
160
- 'jwt.claims.user_id': req.token.user_id,
161
- ...context,
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
- return {
167
- pgSettings: {
168
- role: anonRole,
169
- ...context,
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.11.5",
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.10.2",
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.7",
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": "71058a2aa53cc20255502068b0f0615c384d93d2"
94
+ "gitHead": "d7ad4d8a95a9ab73c9eee919e0cdfcc2334845af"
95
95
  }