@contember/engine-content-api 2.2.0-alpha.19 → 2.2.0-alpha.20
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/CLAUDE.md +12 -7
- package/dist/development/index.cjs +23 -0
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +25 -2
- package/dist/development/index.js.map +1 -1
- package/dist/development/src/ExecutionContainer.cjs +4 -3
- package/dist/development/src/ExecutionContainer.cjs.map +1 -1
- package/dist/development/src/ExecutionContainer.js +4 -3
- package/dist/development/src/ExecutionContainer.js.map +1 -1
- package/dist/development/src/acl/Authorizator.cjs +6 -1
- package/dist/development/src/acl/Authorizator.cjs.map +1 -1
- package/dist/development/src/acl/Authorizator.js +6 -1
- package/dist/development/src/acl/Authorizator.js.map +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -1
- package/dist/development/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -1
- package/dist/development/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -1
- package/dist/development/src/introspection/introspection.schema.cjs +2 -2
- package/dist/development/src/introspection/introspection.schema.cjs.map +1 -1
- package/dist/development/src/introspection/introspection.schema.js +2 -2
- package/dist/development/src/introspection/introspection.schema.js.map +1 -1
- package/dist/development/src/mapper/select/SelectHydrator.cjs +56 -15
- package/dist/development/src/mapper/select/SelectHydrator.cjs.map +1 -1
- package/dist/development/src/mapper/select/SelectHydrator.js +56 -15
- package/dist/development/src/mapper/select/SelectHydrator.js.map +1 -1
- package/dist/development/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
- package/dist/development/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.cjs +17 -39
- package/dist/development/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/MutationResolver.js +18 -40
- package/dist/development/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.cjs +4 -5
- package/dist/development/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadHelpers.js +4 -5
- package/dist/development/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.cjs +8 -17
- package/dist/development/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/development/src/resolvers/ReadResolver.js +8 -17
- package/dist/development/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilder.cjs +16 -6
- package/dist/development/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
- package/dist/development/src/schema/GraphQlSchemaBuilder.js +16 -6
- package/dist/development/src/schema/GraphQlSchemaBuilder.js.map +1 -1
- package/dist/development/src/schema/MutationProvider.cjs +21 -8
- package/dist/development/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/development/src/schema/MutationProvider.js +21 -8
- package/dist/development/src/schema/MutationProvider.js.map +1 -1
- package/dist/development/src/schema/QueryProvider.cjs +6 -6
- package/dist/development/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/development/src/schema/QueryProvider.js +6 -6
- package/dist/development/src/schema/QueryProvider.js.map +1 -1
- package/dist/development/src/schema-json/GraphQLJsBridge.cjs +108 -0
- package/dist/development/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
- package/dist/development/src/schema-json/GraphQLJsBridge.js +108 -0
- package/dist/development/src/schema-json/GraphQLJsBridge.js.map +1 -0
- package/dist/development/src/schema-json/JsonColumnTypes.cjs +102 -0
- package/dist/development/src/schema-json/JsonColumnTypes.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonColumnTypes.js +102 -0
- package/dist/development/src/schema-json/JsonColumnTypes.js.map +1 -0
- package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
- package/dist/development/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonContentSchemaBuilder.js +418 -0
- package/dist/development/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
- package/dist/development/src/schema-json/JsonContentSchemaShared.cjs +18 -0
- package/dist/development/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonContentSchemaShared.js +18 -0
- package/dist/development/src/schema-json/JsonContentSchemaShared.js.map +1 -0
- package/dist/development/src/schema-json/JsonEntityTypes.cjs +206 -0
- package/dist/development/src/schema-json/JsonEntityTypes.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonEntityTypes.js +206 -0
- package/dist/development/src/schema-json/JsonEntityTypes.js.map +1 -0
- package/dist/development/src/schema-json/JsonFilterTypes.cjs +152 -0
- package/dist/development/src/schema-json/JsonFilterTypes.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonFilterTypes.js +152 -0
- package/dist/development/src/schema-json/JsonFilterTypes.js.map +1 -0
- package/dist/development/src/schema-json/JsonInputTypes.cjs +256 -0
- package/dist/development/src/schema-json/JsonInputTypes.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonInputTypes.js +256 -0
- package/dist/development/src/schema-json/JsonInputTypes.js.map +1 -0
- package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
- package/dist/development/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonIntrospectionExtension.js +36 -0
- package/dist/development/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
- package/dist/development/src/schema-json/JsonQueryAstFactory.cjs +107 -0
- package/dist/development/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonQueryAstFactory.js +107 -0
- package/dist/development/src/schema-json/JsonQueryAstFactory.js.map +1 -0
- package/dist/development/src/schema-json/JsonTypeRegistry.cjs +230 -0
- package/dist/development/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
- package/dist/development/src/schema-json/JsonTypeRegistry.js +230 -0
- package/dist/development/src/schema-json/JsonTypeRegistry.js.map +1 -0
- package/dist/development/src/utils/ResolveInfoUtils.cjs.map +1 -1
- package/dist/development/src/utils/ResolveInfoUtils.js.map +1 -1
- package/dist/development/src/utils/uniqueWhereFields.cjs +10 -0
- package/dist/development/src/utils/uniqueWhereFields.cjs.map +1 -1
- package/dist/development/src/utils/uniqueWhereFields.js +10 -0
- package/dist/development/src/utils/uniqueWhereFields.js.map +1 -1
- package/dist/production/index.cjs +23 -0
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.js +25 -2
- package/dist/production/index.js.map +1 -1
- package/dist/production/src/ExecutionContainer.cjs +4 -3
- package/dist/production/src/ExecutionContainer.cjs.map +1 -1
- package/dist/production/src/ExecutionContainer.js +4 -3
- package/dist/production/src/ExecutionContainer.js.map +1 -1
- package/dist/production/src/acl/Authorizator.cjs +6 -1
- package/dist/production/src/acl/Authorizator.cjs.map +1 -1
- package/dist/production/src/acl/Authorizator.js +6 -1
- package/dist/production/src/acl/Authorizator.js.map +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.cjs +1 -1
- package/dist/production/src/extensions/hasManyToHasOneReducer/HasManyToHasOneRelationReducerVisitor.js +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.cjs +1 -1
- package/dist/production/src/extensions/paginatedHasMany/PaginatedHasManyFieldProviderVisitor.js +1 -1
- package/dist/production/src/introspection/introspection.schema.cjs +2 -2
- package/dist/production/src/introspection/introspection.schema.cjs.map +1 -1
- package/dist/production/src/introspection/introspection.schema.js +2 -2
- package/dist/production/src/introspection/introspection.schema.js.map +1 -1
- package/dist/production/src/mapper/select/SelectHydrator.cjs +56 -15
- package/dist/production/src/mapper/select/SelectHydrator.cjs.map +1 -1
- package/dist/production/src/mapper/select/SelectHydrator.js +56 -15
- package/dist/production/src/mapper/select/SelectHydrator.js.map +1 -1
- package/dist/production/src/resolvers/GraphQlQueryAstFactory.cjs.map +1 -1
- package/dist/production/src/resolvers/GraphQlQueryAstFactory.js.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.cjs +17 -39
- package/dist/production/src/resolvers/MutationResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/MutationResolver.js +18 -40
- package/dist/production/src/resolvers/MutationResolver.js.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.cjs +4 -5
- package/dist/production/src/resolvers/ReadHelpers.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadHelpers.js +4 -5
- package/dist/production/src/resolvers/ReadHelpers.js.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.cjs +8 -17
- package/dist/production/src/resolvers/ReadResolver.cjs.map +1 -1
- package/dist/production/src/resolvers/ReadResolver.js +8 -17
- package/dist/production/src/resolvers/ReadResolver.js.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilder.cjs +16 -6
- package/dist/production/src/schema/GraphQlSchemaBuilder.cjs.map +1 -1
- package/dist/production/src/schema/GraphQlSchemaBuilder.js +16 -6
- package/dist/production/src/schema/GraphQlSchemaBuilder.js.map +1 -1
- package/dist/production/src/schema/MutationProvider.cjs +21 -8
- package/dist/production/src/schema/MutationProvider.cjs.map +1 -1
- package/dist/production/src/schema/MutationProvider.js +21 -8
- package/dist/production/src/schema/MutationProvider.js.map +1 -1
- package/dist/production/src/schema/QueryProvider.cjs +6 -6
- package/dist/production/src/schema/QueryProvider.cjs.map +1 -1
- package/dist/production/src/schema/QueryProvider.js +6 -6
- package/dist/production/src/schema/QueryProvider.js.map +1 -1
- package/dist/production/src/schema-json/GraphQLJsBridge.cjs +108 -0
- package/dist/production/src/schema-json/GraphQLJsBridge.cjs.map +1 -0
- package/dist/production/src/schema-json/GraphQLJsBridge.js +108 -0
- package/dist/production/src/schema-json/GraphQLJsBridge.js.map +1 -0
- package/dist/production/src/schema-json/JsonColumnTypes.cjs +102 -0
- package/dist/production/src/schema-json/JsonColumnTypes.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonColumnTypes.js +102 -0
- package/dist/production/src/schema-json/JsonColumnTypes.js.map +1 -0
- package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs +418 -0
- package/dist/production/src/schema-json/JsonContentSchemaBuilder.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonContentSchemaBuilder.js +418 -0
- package/dist/production/src/schema-json/JsonContentSchemaBuilder.js.map +1 -0
- package/dist/production/src/schema-json/JsonContentSchemaShared.cjs +18 -0
- package/dist/production/src/schema-json/JsonContentSchemaShared.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonContentSchemaShared.js +18 -0
- package/dist/production/src/schema-json/JsonContentSchemaShared.js.map +1 -0
- package/dist/production/src/schema-json/JsonEntityTypes.cjs +206 -0
- package/dist/production/src/schema-json/JsonEntityTypes.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonEntityTypes.js +206 -0
- package/dist/production/src/schema-json/JsonEntityTypes.js.map +1 -0
- package/dist/production/src/schema-json/JsonFilterTypes.cjs +152 -0
- package/dist/production/src/schema-json/JsonFilterTypes.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonFilterTypes.js +152 -0
- package/dist/production/src/schema-json/JsonFilterTypes.js.map +1 -0
- package/dist/production/src/schema-json/JsonInputTypes.cjs +256 -0
- package/dist/production/src/schema-json/JsonInputTypes.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonInputTypes.js +256 -0
- package/dist/production/src/schema-json/JsonInputTypes.js.map +1 -0
- package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs +36 -0
- package/dist/production/src/schema-json/JsonIntrospectionExtension.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonIntrospectionExtension.js +36 -0
- package/dist/production/src/schema-json/JsonIntrospectionExtension.js.map +1 -0
- package/dist/production/src/schema-json/JsonQueryAstFactory.cjs +107 -0
- package/dist/production/src/schema-json/JsonQueryAstFactory.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonQueryAstFactory.js +107 -0
- package/dist/production/src/schema-json/JsonQueryAstFactory.js.map +1 -0
- package/dist/production/src/schema-json/JsonTypeRegistry.cjs +230 -0
- package/dist/production/src/schema-json/JsonTypeRegistry.cjs.map +1 -0
- package/dist/production/src/schema-json/JsonTypeRegistry.js +230 -0
- package/dist/production/src/schema-json/JsonTypeRegistry.js.map +1 -0
- package/dist/production/src/utils/ResolveInfoUtils.cjs.map +1 -1
- package/dist/production/src/utils/ResolveInfoUtils.js.map +1 -1
- package/dist/production/src/utils/uniqueWhereFields.cjs +10 -0
- package/dist/production/src/utils/uniqueWhereFields.cjs.map +1 -1
- package/dist/production/src/utils/uniqueWhereFields.js +10 -0
- package/dist/production/src/utils/uniqueWhereFields.js.map +1 -1
- package/dist/tests/src/test.d.ts +10 -2
- package/dist/tests/src/test.d.ts.map +1 -1
- package/dist/tests/src/testGraphql.d.ts +18 -5
- package/dist/tests/src/testGraphql.d.ts.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ExecutionContainer.d.ts +1 -0
- package/dist/types/ExecutionContainer.d.ts.map +1 -1
- package/dist/types/acl/Authorizator.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mapper/select/SelectHydrator.d.ts +4 -1
- package/dist/types/mapper/select/SelectHydrator.d.ts.map +1 -1
- package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts +4 -3
- package/dist/types/resolvers/GraphQlQueryAstFactory.d.ts.map +1 -1
- package/dist/types/resolvers/MutationResolver.d.ts +14 -11
- package/dist/types/resolvers/MutationResolver.d.ts.map +1 -1
- package/dist/types/resolvers/ReadHelpers.d.ts +1 -2
- package/dist/types/resolvers/ReadHelpers.d.ts.map +1 -1
- package/dist/types/resolvers/ReadResolver.d.ts +8 -10
- package/dist/types/resolvers/ReadResolver.d.ts.map +1 -1
- package/dist/types/schema/GraphQlSchemaBuilder.d.ts.map +1 -1
- package/dist/types/schema/MutationProvider.d.ts.map +1 -1
- package/dist/types/schema-json/GraphQLJsBridge.d.ts +12 -0
- package/dist/types/schema-json/GraphQLJsBridge.d.ts.map +1 -0
- package/dist/types/schema-json/JsonColumnTypes.d.ts +23 -0
- package/dist/types/schema-json/JsonColumnTypes.d.ts.map +1 -0
- package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts +56 -0
- package/dist/types/schema-json/JsonContentSchemaBuilder.d.ts.map +1 -0
- package/dist/types/schema-json/JsonContentSchemaShared.d.ts +19 -0
- package/dist/types/schema-json/JsonContentSchemaShared.d.ts.map +1 -0
- package/dist/types/schema-json/JsonEntityTypes.d.ts +29 -0
- package/dist/types/schema-json/JsonEntityTypes.d.ts.map +1 -0
- package/dist/types/schema-json/JsonFilterTypes.d.ts +21 -0
- package/dist/types/schema-json/JsonFilterTypes.d.ts.map +1 -0
- package/dist/types/schema-json/JsonInputTypes.d.ts +36 -0
- package/dist/types/schema-json/JsonInputTypes.d.ts.map +1 -0
- package/dist/types/schema-json/JsonIntrospectionExtension.d.ts +5 -0
- package/dist/types/schema-json/JsonIntrospectionExtension.d.ts.map +1 -0
- package/dist/types/schema-json/JsonQueryAstFactory.d.ts +18 -0
- package/dist/types/schema-json/JsonQueryAstFactory.d.ts.map +1 -0
- package/dist/types/schema-json/JsonTypeRegistry.d.ts +57 -0
- package/dist/types/schema-json/JsonTypeRegistry.d.ts.map +1 -0
- package/dist/types/schema-json/index.d.ts +7 -0
- package/dist/types/schema-json/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/utils/ResolveInfoUtils.d.ts +4 -2
- package/dist/types/utils/ResolveInfoUtils.d.ts.map +1 -1
- package/dist/types/utils/uniqueWhereFields.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/ExecutionContainer.ts +5 -3
- package/src/acl/Authorizator.ts +7 -1
- package/src/index.ts +1 -0
- package/src/mapper/select/SelectHydrator.ts +72 -17
- package/src/resolvers/GraphQlQueryAstFactory.ts +2 -2
- package/src/resolvers/MutationResolver.ts +22 -45
- package/src/resolvers/ReadHelpers.ts +1 -4
- package/src/resolvers/ReadResolver.ts +7 -18
- package/src/schema/GraphQlSchemaBuilder.ts +18 -7
- package/src/schema/MutationProvider.ts +21 -8
- package/src/schema/QueryProvider.ts +6 -6
- package/src/schema-json/GraphQLJsBridge.ts +142 -0
- package/src/schema-json/JsonColumnTypes.ts +116 -0
- package/src/schema-json/JsonContentSchemaBuilder.ts +501 -0
- package/src/schema-json/JsonContentSchemaShared.ts +19 -0
- package/src/schema-json/JsonEntityTypes.ts +237 -0
- package/src/schema-json/JsonFilterTypes.ts +159 -0
- package/src/schema-json/JsonInputTypes.ts +305 -0
- package/src/schema-json/JsonIntrospectionExtension.ts +37 -0
- package/src/schema-json/JsonQueryAstFactory.ts +128 -0
- package/src/schema-json/JsonTypeRegistry.ts +286 -0
- package/src/schema-json/index.ts +6 -0
- package/src/tsconfig.json +1 -0
- package/src/utils/ResolveInfoUtils.ts +2 -2
- package/src/utils/uniqueWhereFields.ts +14 -0
- package/tests/cases/integration/graphQlRequests/insert/memoryBudget.test.ts +2 -3
- package/tests/cases/integration/graphQlRequests/query/graphqlFeatures/alias.test.ts +44 -1
- package/tests/cases/integration/graphQlSchema/graphQlSchemaBuilder.test.ts +25 -29
- package/tests/src/test.ts +44 -10
- package/tests/src/testGraphql.ts +43 -20
- package/tests/tsconfig.json +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { FieldNode as GraphQlFieldNode
|
|
1
|
+
import { FieldNode as GraphQlFieldNode } from 'graphql';
|
|
2
2
|
export declare class ResolveInfoUtils {
|
|
3
|
-
static extractFieldNode(info:
|
|
3
|
+
static extractFieldNode(info: {
|
|
4
|
+
readonly fieldNodes: readonly GraphQlFieldNode[];
|
|
5
|
+
}): GraphQlFieldNode;
|
|
4
6
|
private static mergeFieldNodes;
|
|
5
7
|
}
|
|
6
8
|
//# sourceMappingURL=ResolveInfoUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResolveInfoUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/ResolveInfoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ResolveInfoUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/ResolveInfoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAoB,MAAM,SAAS,CAAA;AAEzE,qBAAa,gBAAgB;IAC5B,OAAc,gBAAgB,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAA;KAAE,GAAG,gBAAgB,CAW3G;IAED,OAAO,CAAC,MAAM,CAAC,eAAe;CAY9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueWhereFields.d.ts","sourceRoot":"","sources":["../../../src/utils/uniqueWhereFields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC,KAAK,YAAY,GAAG,SAAS,MAAM,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"uniqueWhereFields.d.ts","sourceRoot":"","sources":["../../../src/utils/uniqueWhereFields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzC,KAAK,YAAY,GAAG,SAAS,MAAM,EAAE,CAAA;AAKrC,eAAO,MAAM,uBAAuB,WAAY,KAAK,CAAC,MAAM,UAAU,KAAK,CAAC,MAAM,KAAG,SAAS,CAAC,YAAY,CAAC,EAQ3G,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-content-api",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.20",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/production/index.js",
|
|
6
6
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -26,17 +26,18 @@
|
|
|
26
26
|
"generate": "gql-gen --config graphql.codegen.yml"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contember/database": "2.2.0-alpha.
|
|
30
|
-
"@contember/dic": "2.2.0-alpha.
|
|
31
|
-
"@contember/graphql-
|
|
32
|
-
"@contember/
|
|
33
|
-
"@contember/
|
|
34
|
-
"@contember/schema
|
|
35
|
-
"@contember/schema-
|
|
36
|
-
"@contember/
|
|
29
|
+
"@contember/database": "2.2.0-alpha.20",
|
|
30
|
+
"@contember/dic": "2.2.0-alpha.20",
|
|
31
|
+
"@contember/graphql-json": "2.2.0-alpha.20",
|
|
32
|
+
"@contember/graphql-utils": "2.2.0-alpha.20",
|
|
33
|
+
"@contember/logger": "2.2.0-alpha.20",
|
|
34
|
+
"@contember/schema": "2.2.0-alpha.20",
|
|
35
|
+
"@contember/schema-definition": "2.2.0-alpha.20",
|
|
36
|
+
"@contember/schema-utils": "2.2.0-alpha.20",
|
|
37
|
+
"@contember/utilities": "2.2.0-alpha.20"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@contember/database-tester": "2.2.0-alpha.
|
|
40
|
+
"@contember/database-tester": "2.2.0-alpha.20",
|
|
40
41
|
"@types/node": "^24.12.0",
|
|
41
42
|
"graphql": "^16.13.1",
|
|
42
43
|
"pg": "^8.20.0"
|
|
@@ -87,6 +87,7 @@ export type ExecutionContainerArgs = {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface ExecutionContainer {
|
|
90
|
+
queryAstFactory: GraphQlQueryAstFactory
|
|
90
91
|
readResolver: ReadResolver
|
|
91
92
|
mutationResolver: MutationResolver
|
|
92
93
|
validationResolver: ValidationResolver
|
|
@@ -276,7 +277,7 @@ export class ExecutionContainerFactory {
|
|
|
276
277
|
},
|
|
277
278
|
)
|
|
278
279
|
.addService('queryAstFactory', () => new GraphQlQueryAstFactory())
|
|
279
|
-
.addService('readResolver', ({ mapperFactory
|
|
280
|
+
.addService('readResolver', ({ mapperFactory }) => new ReadResolver(mapperFactory))
|
|
280
281
|
.addService('validationDependencyCollector', () => new DependencyCollector())
|
|
281
282
|
.addService('validationQueryAstFactory', ({ schema }) => new QueryAstFactory(schema.model))
|
|
282
283
|
.addService('dataSelector', ({ validationQueryAstFactory, schema }) => new ValidationDataSelector(schema.model, validationQueryAstFactory))
|
|
@@ -289,8 +290,8 @@ export class ExecutionContainerFactory {
|
|
|
289
290
|
)
|
|
290
291
|
.addService(
|
|
291
292
|
'mutationResolver',
|
|
292
|
-
({ mapperFactory, inputPreValidator,
|
|
293
|
-
new MutationResolver(schema.model, mapperFactory, inputPreValidator,
|
|
293
|
+
({ mapperFactory, inputPreValidator, schema, schemaDatabaseMetadata }) =>
|
|
294
|
+
new MutationResolver(schema.model, mapperFactory, inputPreValidator, schemaDatabaseMetadata),
|
|
294
295
|
)
|
|
295
296
|
.addService('validationResolver', ({ inputPreValidator, mapperFactory }) => new ValidationResolver(mapperFactory, inputPreValidator))
|
|
296
297
|
.addService('refreshViewResolver', ({ schema, mapperFactory }) => new RefreshViewResolver(schema, mapperFactory))
|
|
@@ -298,6 +299,7 @@ export class ExecutionContainerFactory {
|
|
|
298
299
|
|
|
299
300
|
public create(args: ExecutionContainerArgs): ExecutionContainer {
|
|
300
301
|
return this.createBuilder(args).build().pick(
|
|
302
|
+
'queryAstFactory',
|
|
301
303
|
'validationResolver',
|
|
302
304
|
'readResolver',
|
|
303
305
|
'mutationResolver',
|
package/src/acl/Authorizator.ts
CHANGED
|
@@ -23,7 +23,13 @@ export class Authorizator {
|
|
|
23
23
|
if (!fieldPermissions) {
|
|
24
24
|
return 'no'
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
// schema builds call this for every relation of every input variant; stop at the first granted field
|
|
27
|
+
for (const field in fieldPermissions) {
|
|
28
|
+
if (fieldPermissions[field]) {
|
|
29
|
+
return 'yes'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return 'no'
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
getFieldPredicate(operation: Acl.Operation.create | Acl.Operation.read | Acl.Operation.update, entity: string, field: string): Acl.Predicate {
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './acl/index.js'
|
|
|
2
2
|
export * from './resolvers/index.js'
|
|
3
3
|
export * from './introspection/index.js'
|
|
4
4
|
export * from './schema/index.js'
|
|
5
|
+
export * from './schema-json/index.js'
|
|
5
6
|
export * from './inputProcessing/index.js'
|
|
6
7
|
export { EntityRulesResolver } from './input-validation/index.js'
|
|
7
8
|
export * from './types.js'
|
|
@@ -25,6 +25,25 @@ type Column = {
|
|
|
25
25
|
getValue: ColumnValueGetter
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** Keys are field aliases, i.e. chosen by the client. */
|
|
29
|
+
type RowLayout = Map<string, RowLayoutEntry>
|
|
30
|
+
|
|
31
|
+
type RowLayoutEntry =
|
|
32
|
+
| { readonly type: 'column'; readonly getValue: ColumnValueGetter }
|
|
33
|
+
| { readonly type: 'object'; readonly layout: RowLayout }
|
|
34
|
+
| { readonly type: 'relation'; readonly relation: ResolvedData }
|
|
35
|
+
|
|
36
|
+
type HydratedObject = { [key: string]: Value.FieldValue }
|
|
37
|
+
|
|
38
|
+
/** An alias may be `__proto__`, which a plain assignment would turn into a prototype change. */
|
|
39
|
+
const setOwnValue = (object: HydratedObject, key: string, value: Value.FieldValue): void => {
|
|
40
|
+
if (key === '__proto__') {
|
|
41
|
+
Object.defineProperty(object, key, { value, enumerable: true, configurable: true, writable: true })
|
|
42
|
+
} else {
|
|
43
|
+
object[key] = value
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
28
47
|
export class SelectHydrator {
|
|
29
48
|
private columns: Column[] = []
|
|
30
49
|
private promises: DataPromises[] = []
|
|
@@ -80,36 +99,72 @@ export class SelectHydrator {
|
|
|
80
99
|
const resolved = await this.resolveDataPromises()
|
|
81
100
|
this.chargeRows(rows.length, resolved.length)
|
|
82
101
|
this.formattedDates = 0
|
|
83
|
-
const
|
|
102
|
+
const layout = this.createRowLayout(resolved)
|
|
103
|
+
const hydrated = rows.map(row => this.hydrateObject(row, layout))
|
|
84
104
|
// A formatted Date is a new string; their count is known only after the rows are built.
|
|
85
105
|
this.memoryBudget?.addHydrationBytes(this.formattedDates * 72)
|
|
86
106
|
return hydrated
|
|
87
107
|
}
|
|
88
108
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
/** Every row has the same shape, so the paths are resolved once instead of per row and column. */
|
|
110
|
+
private createRowLayout(resolvedData: ResolvedData[]): RowLayout {
|
|
111
|
+
const layout: RowLayout = new Map()
|
|
112
|
+
|
|
113
|
+
for (const { path, getValue } of this.columns) {
|
|
114
|
+
const parts = path.path
|
|
115
|
+
let current = layout
|
|
116
|
+
for (const part of parts.slice(0, -1)) {
|
|
117
|
+
const existing = current.get(part)
|
|
118
|
+
if (existing?.type === 'object') {
|
|
119
|
+
current = existing.layout
|
|
120
|
+
} else {
|
|
121
|
+
const nested: RowLayout = new Map()
|
|
122
|
+
current.set(part, { type: 'object', layout: nested })
|
|
123
|
+
current = nested
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
current.set(parts[parts.length - 1], { type: 'column', getValue })
|
|
98
127
|
}
|
|
99
128
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
129
|
+
// a relation lands only in an object the columns created
|
|
130
|
+
for (const relation of resolvedData) {
|
|
131
|
+
const parts = relation.path.path
|
|
132
|
+
let current: RowLayout | undefined = layout
|
|
133
|
+
for (const part of parts.slice(0, -1)) {
|
|
134
|
+
const existing: RowLayoutEntry | undefined = current.get(part)
|
|
135
|
+
current = existing?.type === 'object' ? existing.layout : undefined
|
|
136
|
+
if (!current) {
|
|
137
|
+
break
|
|
138
|
+
}
|
|
107
139
|
}
|
|
140
|
+
current?.set(parts[parts.length - 1], { type: 'relation', relation })
|
|
108
141
|
}
|
|
109
142
|
|
|
143
|
+
return layout
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private hydrateObject(row: SelectRow, layout: RowLayout): SelectResultObject {
|
|
147
|
+
const result: HydratedObject = {}
|
|
148
|
+
for (const [key, entry] of layout) {
|
|
149
|
+
setOwnValue(result, key, this.hydrateEntry(row, entry))
|
|
150
|
+
}
|
|
110
151
|
return result
|
|
111
152
|
}
|
|
112
153
|
|
|
154
|
+
private hydrateEntry(row: SelectRow, entry: RowLayoutEntry): Value.FieldValue {
|
|
155
|
+
switch (entry.type) {
|
|
156
|
+
case 'column':
|
|
157
|
+
return this.formatValue(entry.getValue(row))
|
|
158
|
+
case 'object':
|
|
159
|
+
return this.hydrateObject(row, entry.layout)
|
|
160
|
+
case 'relation': {
|
|
161
|
+
const { getParentValue, data, defaultValue } = entry.relation
|
|
162
|
+
const parentValue = getParentValue(row)
|
|
163
|
+
return (parentValue && Object.hasOwn(data, parentValue) ? data[parentValue] : undefined) || defaultValue
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
113
168
|
private async resolveDataPromises(): Promise<ResolvedData[]> {
|
|
114
169
|
const results = await Promise.allSettled(this.promises.map(async (it): Promise<ResolvedData> => ({
|
|
115
170
|
defaultValue: it.defaultValue,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { FieldNode, ObjectNode } from '../inputProcessing/index.js'
|
|
18
18
|
import { isDeepStrictEqual } from 'node:util'
|
|
19
19
|
|
|
20
|
-
type NodeFilter = (node: GraphQlFieldNode, path: string[]) => boolean
|
|
20
|
+
export type NodeFilter = (node: GraphQlFieldNode, path: string[]) => boolean
|
|
21
21
|
type AnyNode = ObjectNode | FieldNode
|
|
22
22
|
|
|
23
23
|
export class GraphQlQueryAstFactory {
|
|
@@ -119,7 +119,7 @@ export class GraphQlQueryAstFactory {
|
|
|
119
119
|
return typeof val + ' is not supported'
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
public static mergeFieldList(nodes: AnyNode[]): AnyNode[] {
|
|
123
123
|
const result: Record<string, AnyNode> = {}
|
|
124
124
|
for (const node of nodes) {
|
|
125
125
|
result[node.alias] = result[node.alias] ? GraphQlQueryAstFactory.mergeFields(result[node.alias], node) : node
|
|
@@ -14,8 +14,7 @@ import {
|
|
|
14
14
|
tryMutation,
|
|
15
15
|
} from '../mapper/index.js'
|
|
16
16
|
import { ValidationResolver } from './ValidationResolver.js'
|
|
17
|
-
import {
|
|
18
|
-
import { GraphQlQueryAstFactory } from './GraphQlQueryAstFactory.js'
|
|
17
|
+
import { FieldNode as GraphQlFieldNode } from 'graphql'
|
|
19
18
|
import { ImplementationException } from '../exception.js'
|
|
20
19
|
import { DatabaseMetadata, RequestMemoryBudgetExceededError, retryTransaction } from '@contember/database'
|
|
21
20
|
import { Operation, readOperationMeta } from '../schema/index.js'
|
|
@@ -34,7 +33,18 @@ type MemoryBudgetFailure = {
|
|
|
34
33
|
errorMessage: string
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
/** Selects the fields of `mutation { transaction { … } }` that are resolved from the database. */
|
|
37
|
+
export const transactionQueryAstFilter = (node: GraphQlFieldNode, path: string[]): boolean =>
|
|
38
|
+
(path.length === 1 && !['ok', 'validation', 'errorMessage', 'errors'].includes(node.name.value))
|
|
39
|
+
|| (path.length === 2 && node.name.value === 'node')
|
|
40
|
+
|| path.length > 2
|
|
41
|
+
|| path.length === 0
|
|
42
|
+
|| (path.length > 1 && path[1] === 'query')
|
|
43
|
+
|
|
44
|
+
/** Selects the fields of a single mutation result that are resolved from the database. */
|
|
45
|
+
export const mutationResultQueryAstFilter = (node: GraphQlFieldNode, path: string[]): boolean => path.length !== 1 || node.name.value === 'node'
|
|
46
|
+
|
|
47
|
+
export type TransactionOptions = {
|
|
38
48
|
deferForeignKeyConstraints?: boolean
|
|
39
49
|
deferUniqueConstraints?: boolean
|
|
40
50
|
}
|
|
@@ -44,21 +54,11 @@ export class MutationResolver {
|
|
|
44
54
|
private readonly schema: Model.Schema,
|
|
45
55
|
private readonly mapperFactory: MapperFactory,
|
|
46
56
|
private readonly inputValidator: InputPreValidator,
|
|
47
|
-
private readonly graphqlQueryAstFactory: GraphQlQueryAstFactory,
|
|
48
57
|
private readonly schemaDatabaseMetadata: DatabaseMetadata,
|
|
49
58
|
) {}
|
|
50
59
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
(path.length === 1 && !['ok', 'validation', 'errorMessage', 'errors'].includes(node.name.value))
|
|
55
|
-
|| (path.length === 2 && node.name.value === 'node')
|
|
56
|
-
|| path.length > 2
|
|
57
|
-
|| path.length === 0
|
|
58
|
-
|| (path.length > 1 && path[1] === 'query')
|
|
59
|
-
)
|
|
60
|
-
})
|
|
61
|
-
const fields = GraphQlQueryAstFactory.resolveObjectType(info.returnType).getFields()
|
|
60
|
+
/** `queryAst` must be created with `transactionQueryAstFilter`. */
|
|
61
|
+
public async resolveTransaction(queryAst: ObjectNode, options: TransactionOptions): Promise<Result.TransactionResult> {
|
|
62
62
|
const mutationFields = queryAst.fields.filter(field => field.name !== 'query' && field.name !== '__typename')
|
|
63
63
|
|
|
64
64
|
const prefixErrors = <T extends { path: Result.PathFragment[]; paths?: Result.PathFragment[][] }>(
|
|
@@ -91,11 +91,7 @@ export class MutationResolver {
|
|
|
91
91
|
if (!(field instanceof ObjectNode)) {
|
|
92
92
|
throw new ImplementationException()
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
if (!fieldConfig) {
|
|
96
|
-
throw new ImplementationException()
|
|
97
|
-
}
|
|
98
|
-
const meta = readOperationMeta(fieldConfig.extensions)
|
|
94
|
+
const meta = readOperationMeta(field.extensions)
|
|
99
95
|
|
|
100
96
|
const result: Result.ValidationResult | null = await (() => {
|
|
101
97
|
switch (meta.operation) {
|
|
@@ -149,20 +145,12 @@ export class MutationResolver {
|
|
|
149
145
|
if (!(field instanceof ObjectNode)) {
|
|
150
146
|
throw new ImplementationException()
|
|
151
147
|
}
|
|
152
|
-
const fieldConfig = fields[field.name]
|
|
153
|
-
if (!fieldConfig) {
|
|
154
|
-
throw new ImplementationException()
|
|
155
|
-
}
|
|
156
148
|
if (field.name === 'query') {
|
|
157
|
-
trxResult[field.alias] = await executeReadOperations(
|
|
158
|
-
field,
|
|
159
|
-
GraphQlQueryAstFactory.resolveObjectType(fieldConfig.type).getFields(),
|
|
160
|
-
mapper,
|
|
161
|
-
)
|
|
149
|
+
trxResult[field.alias] = await executeReadOperations(field, mapper)
|
|
162
150
|
continue
|
|
163
151
|
}
|
|
164
152
|
|
|
165
|
-
const meta = readOperationMeta(
|
|
153
|
+
const meta = readOperationMeta(field.extensions)
|
|
166
154
|
logger.debug('MutationResolver: Resolving a field', { field: field.alias })
|
|
167
155
|
const result: {
|
|
168
156
|
ok: boolean
|
|
@@ -229,9 +217,8 @@ export class MutationResolver {
|
|
|
229
217
|
|
|
230
218
|
public async resolveUpdate(
|
|
231
219
|
entity: Model.Entity,
|
|
232
|
-
|
|
220
|
+
queryAst: ObjectNode,
|
|
233
221
|
): Promise<WithoutNode<Result.UpdateResult>> {
|
|
234
|
-
const queryAst = this.createQueryAst(info)
|
|
235
222
|
return this.transaction(async mapper => {
|
|
236
223
|
const validation = await this.validateUpdate(mapper, entity, queryAst)
|
|
237
224
|
if (validation !== null) {
|
|
@@ -286,9 +273,8 @@ export class MutationResolver {
|
|
|
286
273
|
|
|
287
274
|
public async resolveCreate(
|
|
288
275
|
entity: Model.Entity,
|
|
289
|
-
|
|
276
|
+
queryAst: ObjectNode,
|
|
290
277
|
): Promise<WithoutNode<Result.CreateResult>> {
|
|
291
|
-
const queryAst = this.createQueryAst(info)
|
|
292
278
|
return this.transaction(async mapper => {
|
|
293
279
|
const validation = await this.validateCreate(mapper, entity, queryAst)
|
|
294
280
|
if (validation !== null) {
|
|
@@ -347,9 +333,8 @@ export class MutationResolver {
|
|
|
347
333
|
|
|
348
334
|
public async resolveUpsert(
|
|
349
335
|
entity: Model.Entity,
|
|
350
|
-
|
|
336
|
+
queryAst: ObjectNode,
|
|
351
337
|
): Promise<WithoutNode<Result.UpsertResult>> {
|
|
352
|
-
const queryAst = this.createQueryAst(info)
|
|
353
338
|
return this.transaction(async mapper => {
|
|
354
339
|
const validation = await this.validateUpsert(mapper, entity, queryAst)
|
|
355
340
|
if (validation !== null) {
|
|
@@ -423,9 +408,8 @@ export class MutationResolver {
|
|
|
423
408
|
|
|
424
409
|
public async resolveDelete(
|
|
425
410
|
entity: Model.Entity,
|
|
426
|
-
|
|
411
|
+
queryAst: ObjectNode,
|
|
427
412
|
): Promise<WithoutNode<Result.DeleteResult>> {
|
|
428
|
-
const queryAst = this.createQueryAst(info)
|
|
429
413
|
return this.transaction(async mapper => {
|
|
430
414
|
return await this.resolveDeleteInternal(mapper, entity, queryAst)
|
|
431
415
|
})
|
|
@@ -452,13 +436,6 @@ export class MutationResolver {
|
|
|
452
436
|
}
|
|
453
437
|
}
|
|
454
438
|
|
|
455
|
-
private createQueryAst(info: GraphQLResolveInfo) {
|
|
456
|
-
const queryAst = this.graphqlQueryAstFactory.create(info, (node, path) => {
|
|
457
|
-
return path.length !== 1 || node.name.value === 'node'
|
|
458
|
-
})
|
|
459
|
-
return queryAst
|
|
460
|
-
}
|
|
461
|
-
|
|
462
439
|
private async resolveResultNodes(
|
|
463
440
|
mapper: Mapper,
|
|
464
441
|
entity: Model.Entity,
|
|
@@ -4,7 +4,6 @@ import { ObjectNode } from '../inputProcessing/index.js'
|
|
|
4
4
|
import { assertNever, createPaginationHelper } from '../utils/index.js'
|
|
5
5
|
import { ImplementationException } from '../exception.js'
|
|
6
6
|
import { Operation, readOperationMeta } from '../schema/index.js'
|
|
7
|
-
import { GraphQLFieldMap } from 'graphql'
|
|
8
7
|
|
|
9
8
|
export const paginate = async (
|
|
10
9
|
mapper: Mapper,
|
|
@@ -22,7 +21,6 @@ export const paginate = async (
|
|
|
22
21
|
|
|
23
22
|
export const executeReadOperations = async (
|
|
24
23
|
queryAst: ObjectNode,
|
|
25
|
-
fields: GraphQLFieldMap<any, any>,
|
|
26
24
|
mapper: Mapper,
|
|
27
25
|
): Promise<Record<string, any>> => {
|
|
28
26
|
const trxResult: Record<string, any> = {}
|
|
@@ -32,8 +30,7 @@ export const executeReadOperations = async (
|
|
|
32
30
|
if (!(field instanceof ObjectNode)) {
|
|
33
31
|
throw new ImplementationException()
|
|
34
32
|
}
|
|
35
|
-
const
|
|
36
|
-
const meta = readOperationMeta(fieldConfig.extensions)
|
|
33
|
+
const meta = readOperationMeta(field.extensions)
|
|
37
34
|
trxResult[field.alias] = await (() => {
|
|
38
35
|
switch (meta.operation) {
|
|
39
36
|
case Operation.get:
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Input, Model } from '@contember/schema'
|
|
2
2
|
import { MapperFactory } from '../mapper/index.js'
|
|
3
|
-
import { GraphQLResolveInfo } from 'graphql'
|
|
4
|
-
import { GraphQlQueryAstFactory } from './GraphQlQueryAstFactory.js'
|
|
5
3
|
import { ObjectNode } from '../inputProcessing/index.js'
|
|
6
4
|
import { executeReadOperations, paginate } from './ReadHelpers.js'
|
|
7
5
|
import { InvalidDataError } from '@contember/database'
|
|
@@ -10,39 +8,30 @@ import { UserError } from '../exception.js'
|
|
|
10
8
|
export class ReadResolver {
|
|
11
9
|
constructor(
|
|
12
10
|
private readonly mapperFactory: MapperFactory,
|
|
13
|
-
private readonly queryAstFactory: GraphQlQueryAstFactory,
|
|
14
11
|
) {}
|
|
15
12
|
|
|
16
|
-
public async resolveQuery(
|
|
17
|
-
const queryAst = this.queryAstFactory.create(info)
|
|
18
|
-
const fields = GraphQlQueryAstFactory.resolveObjectType(info.returnType).getFields()
|
|
13
|
+
public async resolveQuery(queryAst: ObjectNode) {
|
|
19
14
|
const mapper = this.mapperFactory.create()
|
|
20
|
-
return await withInvalidDataAsUserError(() => executeReadOperations(queryAst,
|
|
15
|
+
return await withInvalidDataAsUserError(() => executeReadOperations(queryAst, mapper))
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
public async resolveTransaction(
|
|
24
|
-
const queryAst = this.queryAstFactory.create(info)
|
|
25
|
-
const fields = GraphQlQueryAstFactory.resolveObjectType(info.returnType).getFields()
|
|
26
|
-
|
|
18
|
+
public async resolveTransaction(queryAst: ObjectNode) {
|
|
27
19
|
return await withInvalidDataAsUserError(() =>
|
|
28
20
|
this.mapperFactory.transaction(async mapper => {
|
|
29
|
-
return executeReadOperations(queryAst,
|
|
21
|
+
return executeReadOperations(queryAst, mapper)
|
|
30
22
|
})
|
|
31
23
|
)
|
|
32
24
|
}
|
|
33
25
|
|
|
34
|
-
public async resolveListQuery(entity: Model.Entity,
|
|
35
|
-
const queryAst: ObjectNode<Input.ListQueryInput> = this.queryAstFactory.create(info)
|
|
26
|
+
public async resolveListQuery(entity: Model.Entity, queryAst: ObjectNode<Input.ListQueryInput>) {
|
|
36
27
|
return await withInvalidDataAsUserError(() => this.mapperFactory.create().select(entity, queryAst, []))
|
|
37
28
|
}
|
|
38
29
|
|
|
39
|
-
public async resolveGetQuery(entity: Model.Entity,
|
|
40
|
-
const queryAst: ObjectNode<Input.UniqueQueryInput> = this.queryAstFactory.create(info)
|
|
30
|
+
public async resolveGetQuery(entity: Model.Entity, queryAst: ObjectNode<Input.UniqueQueryInput>) {
|
|
41
31
|
return await withInvalidDataAsUserError(() => this.mapperFactory.create().selectUnique(entity, queryAst, []))
|
|
42
32
|
}
|
|
43
33
|
|
|
44
|
-
public async resolvePaginationQuery(entity: Model.Entity,
|
|
45
|
-
const queryAst: ObjectNode<Input.PaginationQueryInput> = this.queryAstFactory.create(info)
|
|
34
|
+
public async resolvePaginationQuery(entity: Model.Entity, queryAst: ObjectNode<Input.PaginationQueryInput>) {
|
|
46
35
|
const mapper = this.mapperFactory.create()
|
|
47
36
|
return await withInvalidDataAsUserError(() => paginate(mapper, entity, queryAst))
|
|
48
37
|
}
|
|
@@ -16,6 +16,7 @@ import { ValidationQueriesProvider } from './ValidationQueriesProvider.js'
|
|
|
16
16
|
import { Context } from '../types.js'
|
|
17
17
|
import { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'
|
|
18
18
|
import { RefreshViewMutationProvider } from './RefreshViewMutationProvider.js'
|
|
19
|
+
import { transactionQueryAstFilter } from '../resolvers/MutationResolver.js'
|
|
19
20
|
|
|
20
21
|
type BuildArgs = {
|
|
21
22
|
queries?: Map<string, GraphQLFieldConfig<any, Context, any>>
|
|
@@ -63,7 +64,10 @@ export class GraphQlSchemaBuilder {
|
|
|
63
64
|
queries.set('transaction', {
|
|
64
65
|
type: queryTransactionType,
|
|
65
66
|
resolve: async (parent, args, context: Context, info) => {
|
|
66
|
-
return context.timer(
|
|
67
|
+
return context.timer(
|
|
68
|
+
`GraphQL.query.${info.fieldName}`,
|
|
69
|
+
async () => context.executionContainer.readResolver.resolveTransaction(context.executionContainer.queryAstFactory.create(info)),
|
|
70
|
+
)
|
|
67
71
|
},
|
|
68
72
|
})
|
|
69
73
|
}
|
|
@@ -109,16 +113,23 @@ export class GraphQlSchemaBuilder {
|
|
|
109
113
|
context: Context,
|
|
110
114
|
info,
|
|
111
115
|
) => {
|
|
112
|
-
return context.timer(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
return context.timer(
|
|
117
|
+
`GraphQL.mutation.${info.fieldName}`,
|
|
118
|
+
async () =>
|
|
119
|
+
context.executionContainer.mutationResolver.resolveTransaction(
|
|
120
|
+
context.executionContainer.queryAstFactory.create(info, transactionQueryAstFilter),
|
|
121
|
+
{
|
|
122
|
+
deferForeignKeyConstraints: args.options?.deferForeignKeyConstraints ?? false,
|
|
123
|
+
deferUniqueConstraints: args.options?.deferUniqueConstraints ?? false,
|
|
124
|
+
},
|
|
125
|
+
),
|
|
126
|
+
)
|
|
117
127
|
},
|
|
118
128
|
})
|
|
119
129
|
mutations.set('query', {
|
|
120
130
|
type: new GraphQLNonNull(queryObjectType),
|
|
121
|
-
resolve: (parent, args, context: Context, info) =>
|
|
131
|
+
resolve: (parent, args, context: Context, info) =>
|
|
132
|
+
context.executionContainer.readResolver.resolveQuery(context.executionContainer.queryAstFactory.create(info)),
|
|
122
133
|
})
|
|
123
134
|
}
|
|
124
135
|
|
|
@@ -9,6 +9,7 @@ import { filterObject } from '../utils/index.js'
|
|
|
9
9
|
import { aliasAwareResolver, GqlTypeName } from './utils.js'
|
|
10
10
|
import { ResultSchemaTypeProvider } from './ResultSchemaTypeProvider.js'
|
|
11
11
|
import { ExtensionKey, Operation, OperationMeta } from './OperationExtension.js'
|
|
12
|
+
import { mutationResultQueryAstFilter } from '../resolvers/MutationResolver.js'
|
|
12
13
|
|
|
13
14
|
type FieldConfig<TArgs> = GraphQLFieldConfig<any, Context, TArgs>
|
|
14
15
|
|
|
@@ -61,11 +62,14 @@ export class MutationProvider {
|
|
|
61
62
|
},
|
|
62
63
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.create, entity) },
|
|
63
64
|
resolve: (parent, args, context: Context, info) => {
|
|
64
|
-
return context.timer(`GraphQL.mutation.${info.fieldName}`, () => {
|
|
65
|
+
return context.timer(`GraphQL.mutation.${info.fieldName}`, async () => {
|
|
65
66
|
if (parent && info.path) {
|
|
66
67
|
return parent[info.path.key]
|
|
67
68
|
}
|
|
68
|
-
return context.executionContainer.mutationResolver.resolveCreate(
|
|
69
|
+
return context.executionContainer.mutationResolver.resolveCreate(
|
|
70
|
+
entity,
|
|
71
|
+
context.executionContainer.queryAstFactory.create(info, mutationResultQueryAstFilter),
|
|
72
|
+
)
|
|
69
73
|
})
|
|
70
74
|
},
|
|
71
75
|
}
|
|
@@ -96,11 +100,14 @@ export class MutationProvider {
|
|
|
96
100
|
},
|
|
97
101
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.delete, entity) },
|
|
98
102
|
resolve: (parent, args, context: Context, info) => {
|
|
99
|
-
return context.timer(`GraphQL.mutation.${info.fieldName}`, () => {
|
|
103
|
+
return context.timer(`GraphQL.mutation.${info.fieldName}`, async () => {
|
|
100
104
|
if (parent && info.path) {
|
|
101
105
|
return parent[info.path.key]
|
|
102
106
|
}
|
|
103
|
-
return context.executionContainer.mutationResolver.resolveDelete(
|
|
107
|
+
return context.executionContainer.mutationResolver.resolveDelete(
|
|
108
|
+
entity,
|
|
109
|
+
context.executionContainer.queryAstFactory.create(info, mutationResultQueryAstFilter),
|
|
110
|
+
)
|
|
104
111
|
})
|
|
105
112
|
},
|
|
106
113
|
}
|
|
@@ -134,11 +141,14 @@ export class MutationProvider {
|
|
|
134
141
|
},
|
|
135
142
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.update, entity) },
|
|
136
143
|
resolve: (parent, args, context: Context, info) => {
|
|
137
|
-
return context.timer(`GraphQL.${info.fieldName}`, () => {
|
|
144
|
+
return context.timer(`GraphQL.${info.fieldName}`, async () => {
|
|
138
145
|
if (parent && info.path) {
|
|
139
146
|
return parent[info.path.key]
|
|
140
147
|
}
|
|
141
|
-
return context.executionContainer.mutationResolver.resolveUpdate(
|
|
148
|
+
return context.executionContainer.mutationResolver.resolveUpdate(
|
|
149
|
+
entity,
|
|
150
|
+
context.executionContainer.queryAstFactory.create(info, mutationResultQueryAstFilter),
|
|
151
|
+
)
|
|
142
152
|
})
|
|
143
153
|
},
|
|
144
154
|
}
|
|
@@ -181,11 +191,14 @@ export class MutationProvider {
|
|
|
181
191
|
},
|
|
182
192
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.upsert, entity) },
|
|
183
193
|
resolve: (parent, args, context: Context, info) => {
|
|
184
|
-
return context.timer(`GraphQL.${info.fieldName}`, () => {
|
|
194
|
+
return context.timer(`GraphQL.${info.fieldName}`, async () => {
|
|
185
195
|
if (parent && info.path) {
|
|
186
196
|
return parent[info.path.key]
|
|
187
197
|
}
|
|
188
|
-
return context.executionContainer.mutationResolver.resolveUpsert(
|
|
198
|
+
return context.executionContainer.mutationResolver.resolveUpsert(
|
|
199
|
+
entity,
|
|
200
|
+
context.executionContainer.queryAstFactory.create(info, mutationResultQueryAstFilter),
|
|
201
|
+
)
|
|
189
202
|
})
|
|
190
203
|
},
|
|
191
204
|
}
|
|
@@ -52,11 +52,11 @@ export class QueryProvider {
|
|
|
52
52
|
},
|
|
53
53
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.get, entity) },
|
|
54
54
|
resolve: (parent, args, context, info) => {
|
|
55
|
-
return context.timer(`GraphQL.query.${info.fieldName}`, () => {
|
|
55
|
+
return context.timer(`GraphQL.query.${info.fieldName}`, async () => {
|
|
56
56
|
if (parent && info.path) {
|
|
57
57
|
return parent[info.path.key]
|
|
58
58
|
}
|
|
59
|
-
return context.executionContainer.readResolver.resolveGetQuery(entity, info)
|
|
59
|
+
return context.executionContainer.readResolver.resolveGetQuery(entity, context.executionContainer.queryAstFactory.create(info))
|
|
60
60
|
})
|
|
61
61
|
},
|
|
62
62
|
}
|
|
@@ -85,11 +85,11 @@ export class QueryProvider {
|
|
|
85
85
|
},
|
|
86
86
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.list, entity) },
|
|
87
87
|
resolve: (parent, args, context, info) => {
|
|
88
|
-
return context.timer(`GraphQL.query.${info.fieldName}`, () => {
|
|
88
|
+
return context.timer(`GraphQL.query.${info.fieldName}`, async () => {
|
|
89
89
|
if (parent && info.path) {
|
|
90
90
|
return parent[info.path.key]
|
|
91
91
|
}
|
|
92
|
-
return context.executionContainer.readResolver.resolveListQuery(entity, info)
|
|
92
|
+
return context.executionContainer.readResolver.resolveListQuery(entity, context.executionContainer.queryAstFactory.create(info))
|
|
93
93
|
})
|
|
94
94
|
},
|
|
95
95
|
}
|
|
@@ -101,11 +101,11 @@ export class QueryProvider {
|
|
|
101
101
|
deprecationReason: entity.deprecationReason,
|
|
102
102
|
extensions: { [ExtensionKey]: new OperationMeta(Operation.paginate, entity) },
|
|
103
103
|
resolve: (parent, args, context, info) => {
|
|
104
|
-
return context.timer(`GraphQL.query.${info.fieldName}`, () => {
|
|
104
|
+
return context.timer(`GraphQL.query.${info.fieldName}`, async () => {
|
|
105
105
|
if (parent && info.path) {
|
|
106
106
|
return parent[info.path.key]
|
|
107
107
|
}
|
|
108
|
-
return context.executionContainer.readResolver.resolvePaginationQuery(entity, info)
|
|
108
|
+
return context.executionContainer.readResolver.resolvePaginationQuery(entity, context.executionContainer.queryAstFactory.create(info))
|
|
109
109
|
})
|
|
110
110
|
},
|
|
111
111
|
}
|