@commitspark/graphql-api 1.0.0-beta.5 → 1.0.0-beta.7
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/CHANGELOG.md +20 -1
- package/dist/cjs/client.d.ts +28 -0
- package/dist/cjs/client.js +15 -22
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/graphql/apollo-config-factory.d.ts +3 -0
- package/dist/cjs/graphql/apollo-config-factory.js +8 -19
- package/dist/cjs/graphql/apollo-config-factory.js.map +1 -1
- package/dist/cjs/graphql/errors.d.ts +20 -0
- package/dist/cjs/graphql/errors.js +1 -1
- package/dist/cjs/graphql/errors.js.map +1 -1
- package/dist/cjs/graphql/input-type-generator.d.ts +5 -0
- package/dist/cjs/graphql/input-type-generator.js +4 -4
- package/dist/cjs/graphql/input-type-generator.js.map +1 -1
- package/dist/cjs/graphql/queries-mutations-generator.d.ts +17 -0
- package/dist/cjs/graphql/queries-mutations-generator.js +12 -12
- package/dist/cjs/graphql/queries-mutations-generator.js.map +1 -1
- package/dist/cjs/graphql/resolvers/field-resolvers/entry-reference-resolver.d.ts +2 -0
- package/dist/cjs/graphql/resolvers/field-resolvers/entry-reference-resolver.js +7 -16
- package/dist/cjs/graphql/resolvers/field-resolvers/entry-reference-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/field-resolvers/field-default-value-resolver.d.ts +2 -0
- package/dist/cjs/graphql/resolvers/field-resolvers/field-default-value-resolver.js +24 -25
- package/dist/cjs/graphql/resolvers/field-resolvers/field-default-value-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/field-resolvers/types.d.ts +9 -0
- package/dist/cjs/graphql/resolvers/field-resolvers/union-value-resolver.d.ts +2 -0
- package/dist/cjs/graphql/resolvers/field-resolvers/union-value-resolver.js +9 -15
- package/dist/cjs/graphql/resolvers/field-resolvers/union-value-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/object-type-field-default-value-resolver-generator.d.ts +7 -0
- package/dist/cjs/graphql/resolvers/object-type-field-default-value-resolver-generator.js +5 -2
- package/dist/cjs/graphql/resolvers/object-type-field-default-value-resolver-generator.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.d.ts +4 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js +24 -27
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.d.ts +4 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js +23 -23
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.d.ts +4 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js +37 -30
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.d.ts +4 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.js +5 -14
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-every-resolver.d.ts +4 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-every-resolver.js +5 -14
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-every-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.d.ts +3 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.js +4 -13
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/union-type-resolver.d.ts +3 -0
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js +6 -15
- package/dist/cjs/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js.map +1 -1
- package/dist/cjs/graphql/resolvers/types.d.ts +6 -0
- package/dist/cjs/graphql/schema-analyzer.d.ts +8 -0
- package/dist/cjs/graphql/schema-analyzer.js +1 -2
- package/dist/cjs/graphql/schema-analyzer.js.map +1 -1
- package/dist/cjs/graphql/schema-generator.d.ts +3 -0
- package/dist/cjs/graphql/schema-generator.js +82 -85
- package/dist/cjs/graphql/schema-generator.js.map +1 -1
- package/dist/cjs/graphql/schema-root-type-generator.d.ts +2 -0
- package/dist/cjs/graphql/schema-utils/entry-reference-util.d.ts +3 -0
- package/dist/cjs/graphql/schema-utils/entry-reference-util.js +92 -106
- package/dist/cjs/graphql/schema-utils/entry-reference-util.js.map +1 -1
- package/dist/cjs/graphql/schema-utils/entry-type-util.d.ts +4 -0
- package/dist/cjs/graphql/schema-utils/entry-type-util.js +1 -2
- package/dist/cjs/graphql/schema-utils/entry-type-util.js.map +1 -1
- package/dist/cjs/graphql/schema-utils/union-type-util.d.ts +3 -0
- package/dist/cjs/graphql/schema-utils/union-type-util.js +3 -3
- package/dist/cjs/graphql/schema-utils/union-type-util.js.map +1 -1
- package/dist/cjs/graphql/schema-validator.d.ts +2 -0
- package/dist/cjs/graphql/schema-validator.js +3 -7
- package/dist/cjs/graphql/schema-validator.js.map +1 -1
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +8 -19
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/persistence/cache.d.ts +12 -0
- package/dist/cjs/persistence/cache.js +29 -25
- package/dist/cjs/persistence/cache.js.map +1 -1
- package/dist/cjs/persistence/persistence.d.ts +6 -0
- package/dist/cjs/persistence/persistence.js +27 -45
- package/dist/cjs/persistence/persistence.js.map +1 -1
- package/dist/esm/client.js +2 -2
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/graphql/apollo-config-factory.js +1 -1
- package/dist/esm/graphql/apollo-config-factory.js.map +1 -1
- package/dist/esm/graphql/input-type-generator.js +1 -1
- package/dist/esm/graphql/input-type-generator.js.map +1 -1
- package/dist/esm/graphql/queries-mutations-generator.js +6 -6
- package/dist/esm/graphql/queries-mutations-generator.js.map +1 -1
- package/dist/esm/graphql/resolvers/field-resolvers/entry-reference-resolver.js +2 -2
- package/dist/esm/graphql/resolvers/field-resolvers/entry-reference-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/field-resolvers/field-default-value-resolver.js +4 -4
- package/dist/esm/graphql/resolvers/field-resolvers/field-default-value-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/field-resolvers/union-value-resolver.js +1 -1
- package/dist/esm/graphql/resolvers/field-resolvers/union-value-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/object-type-field-default-value-resolver-generator.js +1 -1
- package/dist/esm/graphql/resolvers/object-type-field-default-value-resolver-generator.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js +3 -3
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js +3 -3
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js +3 -3
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.js +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-every-resolver.js +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-every-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.js +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.js.map +1 -1
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js +2 -2
- package/dist/esm/graphql/resolvers/query-mutation-resolvers/union-type-resolver.js.map +1 -1
- package/dist/esm/graphql/schema-generator.js +8 -8
- package/dist/esm/graphql/schema-generator.js.map +1 -1
- package/dist/esm/graphql/schema-utils/entry-reference-util.js +4 -4
- package/dist/esm/graphql/schema-utils/entry-reference-util.js.map +1 -1
- package/dist/esm/graphql/schema-utils/union-type-util.js +1 -1
- package/dist/esm/graphql/schema-utils/union-type-util.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +1 -0
- package/dist/esm/persistence/cache.js +22 -9
- package/dist/esm/persistence/cache.js.map +1 -1
- package/dist/esm/persistence/persistence.js +1 -1
- package/dist/esm/persistence/persistence.js.map +1 -1
- package/dist/types/client.d.ts +1 -1
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/graphql/apollo-config-factory.d.ts +1 -1
- package/dist/types/graphql/apollo-config-factory.d.ts.map +1 -1
- package/dist/types/graphql/input-type-generator.d.ts +1 -1
- package/dist/types/graphql/input-type-generator.d.ts.map +1 -1
- package/dist/types/graphql/queries-mutations-generator.d.ts +1 -1
- package/dist/types/graphql/queries-mutations-generator.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/entry-reference-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/entry-reference-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/field-default-value-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/field-default-value-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/types.d.ts +2 -3
- package/dist/types/graphql/resolvers/field-resolvers/types.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/union-value-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/field-resolvers/union-value-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/object-type-field-default-value-resolver-generator.d.ts +2 -2
- package/dist/types/graphql/resolvers/object-type-field-default-value-resolver-generator.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-every-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-every-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/union-type-resolver.d.ts +1 -1
- package/dist/types/graphql/resolvers/query-mutation-resolvers/union-type-resolver.d.ts.map +1 -1
- package/dist/types/graphql/resolvers/types.d.ts +2 -3
- package/dist/types/graphql/resolvers/types.d.ts.map +1 -1
- package/dist/types/graphql/schema-generator.d.ts +1 -1
- package/dist/types/graphql/schema-generator.d.ts.map +1 -1
- package/dist/types/graphql/schema-root-type-generator.d.ts +1 -1
- package/dist/types/graphql/schema-root-type-generator.d.ts.map +1 -1
- package/dist/types/graphql/schema-utils/entry-reference-util.d.ts +1 -1
- package/dist/types/graphql/schema-utils/entry-reference-util.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/persistence/cache.d.ts +1 -1
- package/dist/types/persistence/cache.d.ts.map +1 -1
- package/dist/types/persistence/persistence.d.ts +1 -1
- package/dist/types/persistence/persistence.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/client.ts +3 -3
- package/src/graphql/apollo-config-factory.ts +2 -2
- package/src/graphql/input-type-generator.ts +2 -2
- package/src/graphql/queries-mutations-generator.ts +8 -8
- package/src/graphql/resolvers/field-resolvers/entry-reference-resolver.ts +3 -3
- package/src/graphql/resolvers/field-resolvers/field-default-value-resolver.ts +5 -5
- package/src/graphql/resolvers/field-resolvers/types.ts +2 -3
- package/src/graphql/resolvers/field-resolvers/union-value-resolver.ts +2 -2
- package/src/graphql/resolvers/object-type-field-default-value-resolver-generator.ts +3 -3
- package/src/graphql/resolvers/query-mutation-resolvers/mutation-create-resolver.ts +4 -4
- package/src/graphql/resolvers/query-mutation-resolvers/mutation-delete-resolver.ts +4 -4
- package/src/graphql/resolvers/query-mutation-resolvers/mutation-update-resolver.ts +4 -4
- package/src/graphql/resolvers/query-mutation-resolvers/query-by-id-resolver.ts +2 -2
- package/src/graphql/resolvers/query-mutation-resolvers/query-every-resolver.ts +2 -2
- package/src/graphql/resolvers/query-mutation-resolvers/query-type-by-id-resolver.ts +2 -2
- package/src/graphql/resolvers/query-mutation-resolvers/union-type-resolver.ts +3 -3
- package/src/graphql/resolvers/types.ts +2 -3
- package/src/graphql/schema-generator.ts +9 -9
- package/src/graphql/schema-root-type-generator.ts +1 -1
- package/src/graphql/schema-utils/entry-reference-util.ts +5 -5
- package/src/graphql/schema-utils/union-type-util.ts +1 -1
- package/src/index.ts +3 -3
- package/src/persistence/cache.ts +43 -10
- package/src/persistence/persistence.ts +2 -2
- package/dist/tsconfig.build.cjs.tsbuildinfo +0 -1
- package/dist/tsconfig.build.esm.tsbuildinfo +0 -1
- package/dist/tsconfig.build.types.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
"gitops",
|
|
10
10
|
"api"
|
|
11
11
|
],
|
|
12
|
-
"version": "1.0.0-beta.
|
|
12
|
+
"version": "1.0.0-beta.7",
|
|
13
13
|
"license": "ISC",
|
|
14
14
|
"private": false,
|
|
15
15
|
"files": [
|
|
16
16
|
"dist/**",
|
|
17
|
+
"!dist/**/*.tsbuildinfo",
|
|
17
18
|
"src/**",
|
|
18
19
|
"README.md",
|
|
19
20
|
"LICENSE",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "npm run build:cjs && npm run build:esm && npm run build:types",
|
|
35
36
|
"build:cjs": "tsc --project tsconfig.build.cjs.json",
|
|
36
|
-
"build:esm": "tsc --project tsconfig.build.esm.json",
|
|
37
|
+
"build:esm": "tsc --project tsconfig.build.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
|
|
37
38
|
"build:types": "tsc --project tsconfig.build.types.json",
|
|
38
39
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
39
40
|
"lint": "eslint \"{src,tests}/**/*.ts\"",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"prepublishOnly": "npm run build"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@apollo/server": "
|
|
46
|
+
"@apollo/server": "^5.2.0",
|
|
46
47
|
"@commitspark/git-adapter": "^0.20.0",
|
|
47
48
|
"@graphql-tools/schema": "^9.0.0",
|
|
48
49
|
"@graphql-tools/utils": "^9.0.0"
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
"@types/jest": "^29.5.2",
|
|
55
56
|
"@types/node": "^22.14.0",
|
|
56
57
|
"eslint": "^9.24.0",
|
|
58
|
+
"eslint-plugin-import": "^2.32.0",
|
|
57
59
|
"globals": "^16.0.0",
|
|
58
60
|
"jest": "^29.5.0",
|
|
59
61
|
"jest-mock-extended": "^3.0.4",
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"prettier": "^2.4.1",
|
|
62
64
|
"ts-jest": "^29.1.0",
|
|
63
65
|
"ts-node": "^10.9.2",
|
|
64
|
-
"typescript": "^5.
|
|
66
|
+
"typescript": "^5.7.0",
|
|
65
67
|
"typescript-eslint": "^8.29.0"
|
|
66
68
|
}
|
|
67
69
|
}
|
package/src/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createApolloConfig } from './graphql/apollo-config-factory'
|
|
2
|
-
import { generateSchema } from './graphql/schema-generator'
|
|
1
|
+
import { createApolloConfig } from './graphql/apollo-config-factory.ts'
|
|
2
|
+
import { generateSchema } from './graphql/schema-generator.ts'
|
|
3
3
|
import {
|
|
4
4
|
DocumentNode,
|
|
5
5
|
GraphQLFormattedError,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ApolloServerOptions,
|
|
12
12
|
GraphQLRequest,
|
|
13
13
|
} from '@apollo/server'
|
|
14
|
-
import { RepositoryCacheHandler } from './persistence/cache'
|
|
14
|
+
import { RepositoryCacheHandler } from './persistence/cache.ts'
|
|
15
15
|
|
|
16
16
|
export type VariableValues = { [name: string]: unknown }
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { makeExecutableSchema } from '@graphql-tools/schema'
|
|
2
|
-
import { generateSchema } from './schema-generator'
|
|
3
|
-
import { ApolloContext } from '../client'
|
|
2
|
+
import { generateSchema } from './schema-generator.ts'
|
|
3
|
+
import { ApolloContext } from '../client.ts'
|
|
4
4
|
import { ApolloServerOptions } from '@apollo/server'
|
|
5
5
|
import { ApolloServerPluginUsageReportingDisabled } from '@apollo/server/plugin/disabled'
|
|
6
6
|
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
isScalarType,
|
|
14
14
|
isUnionType,
|
|
15
15
|
} from 'graphql'
|
|
16
|
-
import { SchemaAnalyzerResult } from './schema-analyzer'
|
|
16
|
+
import { SchemaAnalyzerResult } from './schema-analyzer.ts'
|
|
17
17
|
import {
|
|
18
18
|
buildsOnTypeWithEntryDirective,
|
|
19
19
|
hasEntryDirective,
|
|
20
|
-
} from './schema-utils/entry-type-util'
|
|
20
|
+
} from './schema-utils/entry-type-util.ts'
|
|
21
21
|
|
|
22
22
|
function generateFieldInputTypeString(type: GraphQLNullableType): string {
|
|
23
23
|
if (isListType(type)) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { EntryData } from '@commitspark/git-adapter'
|
|
2
|
-
import { ApolloContext } from '../client'
|
|
2
|
+
import { ApolloContext } from '../client.ts'
|
|
3
3
|
import { GraphQLFieldResolver, GraphQLObjectType } from 'graphql'
|
|
4
|
-
import { queryEveryResolver } from './resolvers/query-mutation-resolvers/query-every-resolver'
|
|
5
|
-
import { queryByIdResolver } from './resolvers/query-mutation-resolvers/query-by-id-resolver'
|
|
6
|
-
import { mutationCreateResolver } from './resolvers/query-mutation-resolvers/mutation-create-resolver'
|
|
7
|
-
import { mutationUpdateResolver } from './resolvers/query-mutation-resolvers/mutation-update-resolver'
|
|
8
|
-
import { mutationDeleteResolver } from './resolvers/query-mutation-resolvers/mutation-delete-resolver'
|
|
9
|
-
import { queryTypeByIdResolver } from './resolvers/query-mutation-resolvers/query-type-by-id-resolver'
|
|
10
|
-
import { QueryMutationResolver } from './resolvers/types'
|
|
4
|
+
import { queryEveryResolver } from './resolvers/query-mutation-resolvers/query-every-resolver.ts'
|
|
5
|
+
import { queryByIdResolver } from './resolvers/query-mutation-resolvers/query-by-id-resolver.ts'
|
|
6
|
+
import { mutationCreateResolver } from './resolvers/query-mutation-resolvers/mutation-create-resolver.ts'
|
|
7
|
+
import { mutationUpdateResolver } from './resolvers/query-mutation-resolvers/mutation-update-resolver.ts'
|
|
8
|
+
import { mutationDeleteResolver } from './resolvers/query-mutation-resolvers/mutation-delete-resolver.ts'
|
|
9
|
+
import { queryTypeByIdResolver } from './resolvers/query-mutation-resolvers/query-type-by-id-resolver.ts'
|
|
10
|
+
import { QueryMutationResolver } from './resolvers/types.ts'
|
|
11
11
|
|
|
12
12
|
export function generateQueriesAndMutations(
|
|
13
13
|
entryDirectiveTypes: GraphQLObjectType[],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FieldResolver, FieldResolverContext } from './types'
|
|
1
|
+
import { FieldResolver, FieldResolverContext } from './types.ts'
|
|
2
2
|
import { GraphQLResolveInfo, isNamedType } from 'graphql'
|
|
3
|
-
import { findById } from '../../../persistence/persistence'
|
|
4
|
-
import { createError, ErrorCode } from '../../errors'
|
|
3
|
+
import { findById } from '../../../persistence/persistence.ts'
|
|
4
|
+
import { createError, ErrorCode } from '../../errors.ts'
|
|
5
5
|
|
|
6
6
|
export const resolveEntryReference: FieldResolver<any> = async (
|
|
7
7
|
fieldValue: any,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldResolver, FieldResolverContext, ResolvedEntryData } from './types'
|
|
1
|
+
import { FieldResolver, FieldResolverContext, ResolvedEntryData } from './types.ts'
|
|
2
2
|
import { EntryData } from '@commitspark/git-adapter'
|
|
3
3
|
import {
|
|
4
4
|
GraphQLNonNull,
|
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
buildsOnTypeWithEntryDirective,
|
|
14
14
|
hasEntryDirective,
|
|
15
|
-
} from '../../schema-utils/entry-type-util'
|
|
16
|
-
import { resolveEntryReference } from './entry-reference-resolver'
|
|
17
|
-
import { resolveUnionValue } from './union-value-resolver'
|
|
18
|
-
import { createError, ErrorCode } from '../../errors'
|
|
15
|
+
} from '../../schema-utils/entry-type-util.ts'
|
|
16
|
+
import { resolveEntryReference } from './entry-reference-resolver.ts'
|
|
17
|
+
import { resolveUnionValue } from './union-value-resolver.ts'
|
|
18
|
+
import { createError, ErrorCode } from '../../errors.ts'
|
|
19
19
|
|
|
20
20
|
export const resolveFieldDefaultValue: FieldResolver<any> = async (
|
|
21
21
|
fieldValue: any,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { GraphQLFieldResolver } from 'graphql
|
|
1
|
+
import { GraphQLFieldResolver, GraphQLOutputType } from 'graphql'
|
|
2
2
|
import { EntryData } from '@commitspark/git-adapter'
|
|
3
|
-
import {
|
|
4
|
-
import { ApolloContext } from '../../../client'
|
|
3
|
+
import { ApolloContext } from '../../../client.ts'
|
|
5
4
|
|
|
6
5
|
export interface FieldResolverContext extends ApolloContext {
|
|
7
6
|
currentType: GraphQLOutputType
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EntryData } from '@commitspark/git-adapter'
|
|
2
|
-
import { FieldResolver, ResolvedEntryData } from './types'
|
|
2
|
+
import { FieldResolver, ResolvedEntryData } from './types.ts'
|
|
3
3
|
import {
|
|
4
4
|
getUnionTypeNameFromFieldValue,
|
|
5
5
|
getUnionValue,
|
|
6
|
-
} from '../../schema-utils/union-type-util'
|
|
6
|
+
} from '../../schema-utils/union-type-util.ts'
|
|
7
7
|
|
|
8
8
|
export const resolveUnionValue: FieldResolver<any> = async (
|
|
9
9
|
fieldValue: any,
|
|
@@ -10,9 +10,9 @@ import {
|
|
|
10
10
|
isUnionType,
|
|
11
11
|
} from 'graphql'
|
|
12
12
|
import { EntryData } from '@commitspark/git-adapter'
|
|
13
|
-
import { ResolvedEntryData } from './field-resolvers/types'
|
|
14
|
-
import { resolveFieldDefaultValue } from './field-resolvers/field-default-value-resolver'
|
|
15
|
-
import { ApolloContext } from '../../client'
|
|
13
|
+
import { ResolvedEntryData } from './field-resolvers/types.ts'
|
|
14
|
+
import { resolveFieldDefaultValue } from './field-resolvers/field-default-value-resolver.ts'
|
|
15
|
+
import { ApolloContext } from '../../client.ts'
|
|
16
16
|
|
|
17
17
|
function requiresCustomDefaultValueResolver(type: GraphQLOutputType): boolean {
|
|
18
18
|
if (isNonNullType(type)) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { findById, findByTypeId } from '../../../persistence/persistence'
|
|
1
|
+
import { findById, findByTypeId } from '../../../persistence/persistence.ts'
|
|
2
2
|
import { GraphQLFieldResolver, isObjectType } from 'graphql'
|
|
3
|
-
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util'
|
|
3
|
+
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util.ts'
|
|
4
4
|
import {
|
|
5
5
|
ENTRY_ID_INVALID_CHARACTERS,
|
|
6
6
|
EntryData,
|
|
7
7
|
EntryDraft,
|
|
8
8
|
} from '@commitspark/git-adapter'
|
|
9
|
-
import { QueryMutationResolverContext } from '../types'
|
|
10
|
-
import { createError, ErrorCode } from '../../errors'
|
|
9
|
+
import { QueryMutationResolverContext } from '../types.ts'
|
|
10
|
+
import { createError, ErrorCode } from '../../errors.ts'
|
|
11
11
|
|
|
12
12
|
export const mutationCreateResolver: GraphQLFieldResolver<
|
|
13
13
|
any,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { findById, findByTypeId } from '../../../persistence/persistence'
|
|
1
|
+
import { findById, findByTypeId } from '../../../persistence/persistence.ts'
|
|
2
2
|
import { Entry, EntryData, EntryDraft } from '@commitspark/git-adapter'
|
|
3
|
-
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util'
|
|
3
|
+
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util.ts'
|
|
4
4
|
import { GraphQLFieldResolver, isObjectType } from 'graphql'
|
|
5
|
-
import { QueryMutationResolverContext } from '../types'
|
|
6
|
-
import { createError, ErrorCode } from '../../errors'
|
|
5
|
+
import { QueryMutationResolverContext } from '../types.ts'
|
|
6
|
+
import { createError, ErrorCode } from '../../errors.ts'
|
|
7
7
|
|
|
8
8
|
export const mutationDeleteResolver: GraphQLFieldResolver<
|
|
9
9
|
any,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { findById, findByTypeId } from '../../../persistence/persistence'
|
|
2
|
-
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util'
|
|
1
|
+
import { findById, findByTypeId } from '../../../persistence/persistence.ts'
|
|
2
|
+
import { getReferencedEntryIds } from '../../schema-utils/entry-reference-util.ts'
|
|
3
3
|
import { GraphQLFieldResolver, isObjectType } from 'graphql'
|
|
4
4
|
import { EntryData, EntryDraft } from '@commitspark/git-adapter'
|
|
5
|
-
import { QueryMutationResolverContext } from '../types'
|
|
6
|
-
import { createError, ErrorCode } from '../../errors'
|
|
5
|
+
import { QueryMutationResolverContext } from '../types.ts'
|
|
6
|
+
import { createError, ErrorCode } from '../../errors.ts'
|
|
7
7
|
|
|
8
8
|
function mergeData(
|
|
9
9
|
existingEntryData: EntryData,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntryData } from '@commitspark/git-adapter'
|
|
2
|
-
import { findByTypeId } from '../../../persistence/persistence'
|
|
2
|
+
import { findByTypeId } from '../../../persistence/persistence.ts'
|
|
3
3
|
import { GraphQLFieldResolver } from 'graphql'
|
|
4
|
-
import { QueryMutationResolverContext } from '../types'
|
|
4
|
+
import { QueryMutationResolverContext } from '../types.ts'
|
|
5
5
|
|
|
6
6
|
export const queryByIdResolver: GraphQLFieldResolver<
|
|
7
7
|
any,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntryData } from '@commitspark/git-adapter'
|
|
2
|
-
import { findByType } from '../../../persistence/persistence'
|
|
2
|
+
import { findByType } from '../../../persistence/persistence.ts'
|
|
3
3
|
import { GraphQLFieldResolver } from 'graphql'
|
|
4
|
-
import { QueryMutationResolverContext } from '../types'
|
|
4
|
+
import { QueryMutationResolverContext } from '../types.ts'
|
|
5
5
|
|
|
6
6
|
export const queryEveryResolver: GraphQLFieldResolver<
|
|
7
7
|
any,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getTypeById } from '../../../persistence/persistence'
|
|
1
|
+
import { getTypeById } from '../../../persistence/persistence.ts'
|
|
2
2
|
import { GraphQLFieldResolver } from 'graphql'
|
|
3
|
-
import { ApolloContext } from '../../../client'
|
|
3
|
+
import { ApolloContext } from '../../../client.ts'
|
|
4
4
|
|
|
5
5
|
export const queryTypeByIdResolver: GraphQLFieldResolver<
|
|
6
6
|
any,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ApolloContext } from '../../../client'
|
|
2
|
-
import { getTypeById } from '../../../persistence/persistence'
|
|
1
|
+
import { ApolloContext } from '../../../client.ts'
|
|
2
|
+
import { getTypeById } from '../../../persistence/persistence.ts'
|
|
3
3
|
import { GraphQLTypeResolver } from 'graphql'
|
|
4
|
-
import { buildsOnTypeWithEntryDirective } from '../../schema-utils/entry-type-util'
|
|
4
|
+
import { buildsOnTypeWithEntryDirective } from '../../schema-utils/entry-type-util.ts'
|
|
5
5
|
|
|
6
6
|
export const unionTypeResolver: GraphQLTypeResolver<
|
|
7
7
|
any,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ApolloContext } from '../../client'
|
|
2
|
-
import { GraphQLNamedType } from 'graphql
|
|
3
|
-
import { GraphQLFieldResolver } from 'graphql'
|
|
1
|
+
import { ApolloContext } from '../../client.ts'
|
|
2
|
+
import { GraphQLFieldResolver, GraphQLNamedType } from 'graphql'
|
|
4
3
|
|
|
5
4
|
export interface QueryMutationResolverContext extends ApolloContext {
|
|
6
5
|
type: GraphQLNamedType
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
generateQueriesAndMutations,
|
|
3
3
|
generateTypeNameQuery,
|
|
4
|
-
} from './queries-mutations-generator'
|
|
4
|
+
} from './queries-mutations-generator.ts'
|
|
5
5
|
import {
|
|
6
6
|
IExecutableSchemaDefinition,
|
|
7
7
|
makeExecutableSchema,
|
|
8
8
|
} from '@graphql-tools/schema'
|
|
9
|
-
import { analyzeSchema } from './schema-analyzer'
|
|
9
|
+
import { analyzeSchema } from './schema-analyzer.ts'
|
|
10
10
|
import {
|
|
11
11
|
generateIdInputTypeStrings,
|
|
12
12
|
generateObjectInputTypeStrings,
|
|
13
13
|
generateUnionInputTypeStrings,
|
|
14
|
-
} from './input-type-generator'
|
|
15
|
-
import { generateSchemaRootTypeStrings } from './schema-root-type-generator'
|
|
14
|
+
} from './input-type-generator.ts'
|
|
15
|
+
import { generateSchemaRootTypeStrings } from './schema-root-type-generator.ts'
|
|
16
16
|
import { printSchemaWithDirectives } from '@graphql-tools/utils'
|
|
17
|
-
import { unionTypeResolver } from './resolvers/query-mutation-resolvers/union-type-resolver'
|
|
18
|
-
import { ApolloContext } from '../client'
|
|
17
|
+
import { unionTypeResolver } from './resolvers/query-mutation-resolvers/union-type-resolver.ts'
|
|
18
|
+
import { ApolloContext } from '../client.ts'
|
|
19
19
|
import { GraphQLFieldResolver, GraphQLTypeResolver } from 'graphql'
|
|
20
|
-
import { getValidationResult } from './schema-validator'
|
|
20
|
+
import { getValidationResult } from './schema-validator.ts'
|
|
21
21
|
import { EntryData } from '@commitspark/git-adapter'
|
|
22
|
-
import { createObjectTypeFieldResolvers } from './resolvers/object-type-field-default-value-resolver-generator'
|
|
23
|
-
import { createError, ErrorCode } from './errors'
|
|
22
|
+
import { createObjectTypeFieldResolvers } from './resolvers/object-type-field-default-value-resolver-generator.ts'
|
|
23
|
+
import { createError, ErrorCode } from './errors.ts'
|
|
24
24
|
|
|
25
25
|
export async function generateSchema(
|
|
26
26
|
context: ApolloContext,
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
isObjectType,
|
|
7
7
|
isUnionType,
|
|
8
8
|
} from 'graphql'
|
|
9
|
-
import { ApolloContext } from '../../client'
|
|
10
|
-
import { getTypeById } from '../../persistence/persistence'
|
|
9
|
+
import { ApolloContext } from '../../client.ts'
|
|
10
|
+
import { getTypeById } from '../../persistence/persistence.ts'
|
|
11
11
|
import {
|
|
12
12
|
getUnionTypeNameFromFieldValue,
|
|
13
13
|
getUnionValue,
|
|
14
|
-
} from './union-type-util'
|
|
15
|
-
import { hasEntryDirective, isUnionOfEntryTypes } from './entry-type-util'
|
|
16
|
-
import { createError, ErrorCode } from '../errors'
|
|
14
|
+
} from './union-type-util.ts'
|
|
15
|
+
import { hasEntryDirective, isUnionOfEntryTypes } from './entry-type-util.ts'
|
|
16
|
+
import { createError, ErrorCode } from '../errors.ts'
|
|
17
17
|
|
|
18
18
|
function isPermittedReferenceType(
|
|
19
19
|
referencedTypeName: string,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntryData } from '@commitspark/git-adapter'
|
|
2
|
-
import { createError, ErrorCode } from '../errors'
|
|
2
|
+
import { createError, ErrorCode } from '../errors.ts'
|
|
3
3
|
|
|
4
4
|
export function getUnionTypeNameFromFieldValue(fieldValue: unknown): string {
|
|
5
5
|
if (typeof fieldValue !== 'object' || fieldValue === null) {
|
package/src/index.ts
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
postGraphQL,
|
|
6
6
|
SchemaResponse,
|
|
7
7
|
VariableValues,
|
|
8
|
-
} from './client'
|
|
8
|
+
} from './client.ts'
|
|
9
9
|
import { GitAdapter } from '@commitspark/git-adapter'
|
|
10
|
-
import { ErrorCode, ErrorMetadata } from './graphql/errors'
|
|
11
|
-
import { createCacheHandler } from './persistence/cache'
|
|
10
|
+
import { ErrorCode, ErrorMetadata } from './graphql/errors.ts'
|
|
11
|
+
import { createCacheHandler } from './persistence/cache.ts'
|
|
12
12
|
|
|
13
13
|
interface Client {
|
|
14
14
|
postGraphQL<
|
package/src/persistence/cache.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Entry, GitAdapterError } from '@commitspark/git-adapter'
|
|
2
|
-
import { ApolloContext } from '../client'
|
|
3
|
-
import { createError } from '../graphql/errors'
|
|
2
|
+
import { ApolloContext } from '../client.ts'
|
|
3
|
+
import { createError, ErrorCode } from '../graphql/errors.ts'
|
|
4
4
|
|
|
5
5
|
type Ref = string
|
|
6
6
|
type EntriesCache = Map<Ref, EntriesRecord>
|
|
7
7
|
type SchemaCache = Map<Ref, string>
|
|
8
|
+
type InflightEntries = Map<Ref, Promise<EntriesRecord>>
|
|
8
9
|
|
|
9
10
|
interface EntriesRecord {
|
|
10
11
|
byId: Map<string, Entry>
|
|
@@ -21,8 +22,10 @@ export interface RepositoryCacheHandler {
|
|
|
21
22
|
|
|
22
23
|
const MAX_CACHE_ENTRIES = 50
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
// intentionally not async so that the same in-flight promise is returned to all callers
|
|
26
|
+
const getEntriesRecordByRef = (
|
|
25
27
|
entriesCache: EntriesCache,
|
|
28
|
+
inflightEntries: InflightEntries,
|
|
26
29
|
cacheSize: number,
|
|
27
30
|
context: ApolloContext,
|
|
28
31
|
ref: string,
|
|
@@ -33,9 +36,32 @@ const getEntriesRecordByRef = async (
|
|
|
33
36
|
entriesCache.delete(ref)
|
|
34
37
|
entriesCache.set(ref, cacheRecord)
|
|
35
38
|
|
|
36
|
-
return cacheRecord
|
|
39
|
+
return Promise.resolve(cacheRecord)
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
const inflightPromise = inflightEntries.get(ref)
|
|
43
|
+
if (inflightPromise) {
|
|
44
|
+
return inflightPromise
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const fetchPromise = fetchAndCacheEntries(
|
|
48
|
+
entriesCache,
|
|
49
|
+
cacheSize,
|
|
50
|
+
context,
|
|
51
|
+
ref,
|
|
52
|
+
).finally(() => inflightEntries.delete(ref))
|
|
53
|
+
|
|
54
|
+
inflightEntries.set(ref, fetchPromise)
|
|
55
|
+
|
|
56
|
+
return fetchPromise
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fetchAndCacheEntries = async (
|
|
60
|
+
entriesCache: EntriesCache,
|
|
61
|
+
cacheSize: number,
|
|
62
|
+
context: ApolloContext,
|
|
63
|
+
ref: string,
|
|
64
|
+
): Promise<EntriesRecord> => {
|
|
39
65
|
let allEntries: Entry[]
|
|
40
66
|
try {
|
|
41
67
|
allEntries = await context.gitAdapter.getEntries(ref)
|
|
@@ -43,14 +69,16 @@ const getEntriesRecordByRef = async (
|
|
|
43
69
|
if (err instanceof GitAdapterError) {
|
|
44
70
|
throw createError(err.message, err.code, {})
|
|
45
71
|
}
|
|
46
|
-
|
|
72
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
73
|
+
throw createError(message, ErrorCode.INTERNAL_ERROR, {})
|
|
47
74
|
}
|
|
75
|
+
|
|
48
76
|
const entriesById = new Map(allEntries.map((entry) => [entry.id, entry]))
|
|
49
77
|
const entriesByType = new Map<string, Entry[]>()
|
|
50
78
|
for (const entry of allEntries) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
entriesByType.set(entry.metadata.type,
|
|
79
|
+
const existingEntriesOfType = entriesByType.get(entry.metadata.type) || []
|
|
80
|
+
existingEntriesOfType.push(entry)
|
|
81
|
+
entriesByType.set(entry.metadata.type, existingEntriesOfType)
|
|
54
82
|
}
|
|
55
83
|
|
|
56
84
|
const newCacheRecord = {
|
|
@@ -93,7 +121,8 @@ const getSchemaStringByRef = async (
|
|
|
93
121
|
if (err instanceof GitAdapterError) {
|
|
94
122
|
throw createError(err.message, err.code, {})
|
|
95
123
|
}
|
|
96
|
-
|
|
124
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
125
|
+
throw createError(message, ErrorCode.INTERNAL_ERROR, {})
|
|
97
126
|
}
|
|
98
127
|
|
|
99
128
|
schemaCache.set(ref, schemaString)
|
|
@@ -114,9 +143,13 @@ export const createCacheHandler = (
|
|
|
114
143
|
): RepositoryCacheHandler => {
|
|
115
144
|
const entriesCache: EntriesCache = new Map<Ref, EntriesRecord>()
|
|
116
145
|
const schemaCache: SchemaCache = new Map<Ref, string>()
|
|
146
|
+
const inflightEntries: InflightEntries = new Map<
|
|
147
|
+
Ref,
|
|
148
|
+
Promise<EntriesRecord>
|
|
149
|
+
>()
|
|
117
150
|
return {
|
|
118
151
|
getEntriesRecord: (...args) =>
|
|
119
|
-
getEntriesRecordByRef(entriesCache, cacheSize, ...args),
|
|
152
|
+
getEntriesRecordByRef(entriesCache, inflightEntries, cacheSize, ...args),
|
|
120
153
|
getSchema: (...args) =>
|
|
121
154
|
getSchemaStringByRef(schemaCache, cacheSize, ...args),
|
|
122
155
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Entry } from '@commitspark/git-adapter'
|
|
2
|
-
import { createError, ErrorCode } from '../graphql/errors'
|
|
3
|
-
import { ApolloContext } from '../client'
|
|
2
|
+
import { createError, ErrorCode } from '../graphql/errors.ts'
|
|
3
|
+
import { ApolloContext } from '../client.ts'
|
|
4
4
|
|
|
5
5
|
export async function getTypeById(
|
|
6
6
|
context: ApolloContext,
|