@contember/binding 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contember/binding",
3
3
  "license": "Apache-2.0",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/production/index.js",
@@ -19,10 +19,10 @@
19
19
  ],
20
20
  "typings": "./dist/types/index.d.ts",
21
21
  "dependencies": {
22
- "@contember/client": "1.0.0",
23
- "@contember/react-client": "1.0.0",
24
- "@contember/react-multipass-rendering": "1.0.0",
25
- "@contember/react-utils": "1.0.0",
22
+ "@contember/client": "1.0.1",
23
+ "@contember/react-client": "1.0.1",
24
+ "@contember/react-multipass-rendering": "1.0.1",
25
+ "@contember/react-utils": "1.0.1",
26
26
  "chevrotain": "6.5.0",
27
27
  "js-levenshtein": "1.1.6",
28
28
  "uuid": "8.3.2"
@@ -52,4 +52,5 @@ export interface MutationTransactionResponse {
52
52
 
53
53
  export interface MutationRequestResponse {
54
54
  data: MutationTransactionResponse | null
55
+ errors?: { message: string, path?: string[] }[]
55
56
  }
@@ -16,4 +16,5 @@ export interface ReceivedDataTree<A = never> {
16
16
 
17
17
  export interface QueryRequestResponse<A = never> {
18
18
  data: ReceivedDataTree<A>
19
+ errors?: { message: string, path?: string[] }[]
19
20
  }
@@ -13,4 +13,10 @@ export interface UnknownErrorRequestError {
13
13
  type: 'unknownError'
14
14
  }
15
15
 
16
- export type RequestError = UnauthorizedRequestError | NetworkErrorRequestError | UnknownErrorRequestError
16
+ export interface GqlError {
17
+ type: 'gqlError'
18
+ query: string,
19
+ errors: { message: string, path?: string[] }[]
20
+ }
21
+
22
+ export type RequestError = UnauthorizedRequestError | NetworkErrorRequestError | GqlError | UnknownErrorRequestError
@@ -163,6 +163,15 @@ export class DataBinding {
163
163
  const mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {
164
164
  signal,
165
165
  })
166
+
167
+ if (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {
168
+ this.onError({
169
+ type: 'gqlError',
170
+ query: mutation,
171
+ errors: mutationResponse.errors,
172
+ })
173
+ }
174
+
166
175
  const mutationData = mutationResponse.data?.transaction ?? {}
167
176
  const aliases = Object.keys(mutationData)
168
177
  if (!mutationResponse.data) {
@@ -383,6 +392,15 @@ export class DataBinding {
383
392
  }
384
393
  this.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))
385
394
  }
395
+
396
+ if (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {
397
+ this.onError({
398
+ type: 'gqlError',
399
+ query: query ?? 'unknown query',
400
+ errors: queryResponse.errors,
401
+ })
402
+ }
403
+
386
404
  return queryResponse
387
405
  }
388
406
 
@@ -153,11 +153,9 @@ export class StateInitializer {
153
153
  if (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {
154
154
  throw new BindingError()
155
155
  }
156
+ runtimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId()
156
157
  if (value.type === 'entityRealm') {
157
158
  subCopyFrom = value
158
- runtimeId = value.entity.id
159
- } else {
160
- runtimeId = new UnpersistedEntityDummyId()
161
159
  }
162
160
  }
163
161
  this.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)