@contember/engine-http 1.3.4 → 1.3.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/src/application/application.d.ts.map +1 -1
- package/dist/src/application/application.js +2 -0
- package/dist/src/application/application.js.map +1 -1
- package/dist/src/content/GraphQLSchemaContributor.d.ts +2 -2
- package/dist/src/content/GraphQLSchemaContributor.d.ts.map +1 -1
- package/dist/src/content/GraphQlSchemaFactory.d.ts.map +1 -1
- package/dist/src/content/GraphQlSchemaFactory.js +30 -16
- package/dist/src/content/GraphQlSchemaFactory.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -15
- package/src/application/application.ts +3 -1
- package/src/content/GraphQLSchemaContributor.ts +2 -2
- package/src/content/GraphQlSchemaFactory.ts +33 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-http",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"typings": "dist/src/index.d.ts",
|
|
@@ -13,20 +13,20 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@apollographql/graphql-playground-html": "^1.6.24",
|
|
16
|
-
"@contember/config-loader": "1.3.
|
|
17
|
-
"@contember/database": "1.3.
|
|
18
|
-
"@contember/database-migrations": "1.3.
|
|
19
|
-
"@contember/dic": "1.3.
|
|
20
|
-
"@contember/engine-common": "1.3.
|
|
21
|
-
"@contember/engine-content-api": "1.3.
|
|
22
|
-
"@contember/engine-system-api": "1.3.
|
|
23
|
-
"@contember/engine-tenant-api": "1.3.
|
|
24
|
-
"@contember/graphql-utils": "1.3.
|
|
25
|
-
"@contember/logger": "1.3.
|
|
26
|
-
"@contember/schema": "1.3.
|
|
27
|
-
"@contember/schema-migrations": "1.3.
|
|
28
|
-
"@contember/schema-utils": "1.3.
|
|
29
|
-
"@contember/typesafe": "1.3.
|
|
16
|
+
"@contember/config-loader": "1.3.6",
|
|
17
|
+
"@contember/database": "1.3.6",
|
|
18
|
+
"@contember/database-migrations": "1.3.6",
|
|
19
|
+
"@contember/dic": "1.3.6",
|
|
20
|
+
"@contember/engine-common": "1.3.6",
|
|
21
|
+
"@contember/engine-content-api": "1.3.6",
|
|
22
|
+
"@contember/engine-system-api": "1.3.6",
|
|
23
|
+
"@contember/engine-tenant-api": "1.3.6",
|
|
24
|
+
"@contember/graphql-utils": "1.3.6",
|
|
25
|
+
"@contember/logger": "1.3.6",
|
|
26
|
+
"@contember/schema": "1.3.6",
|
|
27
|
+
"@contember/schema-migrations": "1.3.6",
|
|
28
|
+
"@contember/schema-utils": "1.3.6",
|
|
29
|
+
"@contember/typesafe": "1.3.6",
|
|
30
30
|
"@graphql-tools/merge": "^8.3.5",
|
|
31
31
|
"@graphql-tools/schema": "^8.3.5",
|
|
32
32
|
"@koa/cors": "^3.1.0",
|
|
@@ -170,7 +170,7 @@ export class Application {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
private async handleHttpRequest(ctx: KoaContext<{module?: string}>) {
|
|
173
|
+
private async handleHttpRequest(ctx: KoaContext<{ module?: string; projectGroup?: string; project?: string }>) {
|
|
174
174
|
let httpContext: HttpContext | null = null
|
|
175
175
|
let requestLogger = this.logger
|
|
176
176
|
const { timer, send: sendTimer } = this.createTimer()
|
|
@@ -192,6 +192,8 @@ export class Application {
|
|
|
192
192
|
requestLogger = requestLogger.child({
|
|
193
193
|
projectGroup: groupContainer.slug,
|
|
194
194
|
})
|
|
195
|
+
ctx.state.projectGroup = groupContainer.slug
|
|
196
|
+
ctx.state.project = matchedRequest.params.projectSlug
|
|
195
197
|
|
|
196
198
|
const authResult = await groupContainer.authenticator.authenticate({ request: ctx.req, timer })
|
|
197
199
|
requestLogger.debug('User authenticated', { authResult })
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema } from '@contember/schema'
|
|
2
|
-
import { GraphQLSchema } from 'graphql'
|
|
2
|
+
import { GraphQLSchema, GraphQLSchemaConfig } from 'graphql'
|
|
3
3
|
import { Identity } from './Identity'
|
|
4
4
|
|
|
5
5
|
export type GraphQLSchemaContributorContext = { schema: Schema; identity: Identity }
|
|
6
6
|
|
|
7
7
|
export interface GraphQLSchemaContributor {
|
|
8
|
-
createSchema(context: GraphQLSchemaContributorContext): undefined | GraphQLSchema
|
|
8
|
+
createSchema(context: GraphQLSchemaContributorContext): undefined | GraphQLSchema | GraphQLSchemaConfig
|
|
9
9
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Authorizator,
|
|
3
|
+
Context,
|
|
3
4
|
EntityRulesResolver,
|
|
4
5
|
GraphQlSchemaBuilderFactory,
|
|
5
6
|
IntrospectionSchemaDefinitionFactory,
|
|
@@ -7,10 +8,8 @@ import {
|
|
|
7
8
|
PermissionFactory,
|
|
8
9
|
} from '@contember/engine-content-api'
|
|
9
10
|
import { Acl, Schema } from '@contember/schema'
|
|
10
|
-
import { GraphQLSchema } from 'graphql'
|
|
11
|
-
import { makeExecutableSchema, mergeSchemas } from '@graphql-tools/schema'
|
|
11
|
+
import { GraphQLFieldConfig, GraphQLNamedType, GraphQLSchema } from 'graphql'
|
|
12
12
|
import { GraphQLSchemaContributor } from './GraphQLSchemaContributor'
|
|
13
|
-
import { JSONType } from '@contember/graphql-utils'
|
|
14
13
|
import { Identity } from './Identity'
|
|
15
14
|
import { ContentApiSpecificCache } from './ContentApiSpecificCache'
|
|
16
15
|
|
|
@@ -36,29 +35,46 @@ export class GraphQlSchemaFactory {
|
|
|
36
35
|
|
|
37
36
|
const authorizator = new Authorizator(permissions, schema.acl.customPrimary ?? false)
|
|
38
37
|
const dataSchemaBuilder = this.graphqlSchemaBuilderFactory.create(schema.model, authorizator)
|
|
39
|
-
const
|
|
38
|
+
const introspectionSchemaFactory = new IntrospectionSchemaDefinitionFactory(
|
|
40
39
|
new IntrospectionSchemaFactory(
|
|
41
40
|
schema.model,
|
|
42
41
|
new EntityRulesResolver(schema.validation, schema.model),
|
|
43
42
|
authorizator,
|
|
44
43
|
),
|
|
45
44
|
)
|
|
46
|
-
const
|
|
47
|
-
const contentSchema = makeExecutableSchema({
|
|
48
|
-
...contentSchemaFactory.create(),
|
|
49
|
-
resolverValidationOptions: {
|
|
50
|
-
requireResolversForResolveType: 'ignore',
|
|
51
|
-
},
|
|
52
|
-
})
|
|
45
|
+
const introspectionSchema = introspectionSchemaFactory.createConfig()
|
|
53
46
|
|
|
54
47
|
const otherSchemas = this.schemaContributors
|
|
55
48
|
.map(it => it.createSchema({ schema, identity }))
|
|
56
|
-
.filter((it): it is
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
.filter(<T>(it: T | undefined): it is T => it !== undefined)
|
|
50
|
+
|
|
51
|
+
const queries = new Map<string, GraphQLFieldConfig<any, Context, any>>()
|
|
52
|
+
const mutations = new Map<string, GraphQLFieldConfig<any, Context, any>>()
|
|
53
|
+
const types: GraphQLNamedType[] = []
|
|
54
|
+
|
|
55
|
+
for (const schema of [introspectionSchema, ...otherSchemas]) {
|
|
56
|
+
if (schema instanceof GraphQLSchema) {
|
|
57
|
+
for (const [field, config] of Object.entries(schema.getQueryType()?.toConfig().fields ?? {})) {
|
|
58
|
+
queries.set(field, config)
|
|
59
|
+
}
|
|
60
|
+
for (const [field, config] of Object.entries(schema.getQueryType()?.toConfig().fields ?? {})) {
|
|
61
|
+
mutations.set(field, config)
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
for (const [field, config] of Object.entries(schema.query?.toConfig().fields ?? {})) {
|
|
65
|
+
queries.set(field, config)
|
|
66
|
+
}
|
|
67
|
+
for (const [field, config] of Object.entries(schema.mutation?.toConfig().fields ?? {})) {
|
|
68
|
+
mutations.set(field, config)
|
|
69
|
+
}
|
|
70
|
+
types.push(...(schema.types ?? []))
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const graphQlSchema = dataSchemaBuilder.build({
|
|
75
|
+
mutations,
|
|
76
|
+
queries,
|
|
77
|
+
types,
|
|
62
78
|
})
|
|
63
79
|
|
|
64
80
|
return { schema: graphQlSchema, permissions }
|