Loading graphql/urql/worker/cacheConsumer.ts +21 −7 Original line number Diff line number Diff line Loading @@ -594,7 +594,6 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ }) }, exercisesSubscription({ exercisesSubscription }, _args, cache) { console.log('exercisesSubscription', exercisesSubscription) const { exercise: newExercise, eventType } = exercisesSubscription || {} if (!newExercise || !eventType) { return Loading @@ -602,18 +601,33 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ const params = ['Query', 'exercises'] as const switch (eventType) { case 'CREATE': { case 'CREATE': { const linkNot = cache.resolve(...params) || [] if (!Array.isArray(linkNot)) { throw Error('Generic typing error, look up exercisesSub') } /* * only add the exercise if it does not exist; * this can happen when the exercise is created: * 1. the MODIFY event is sent because the creator is assigned as an instructor * 2. the CREATE event is sent because the exercise is created * * the CREATE event has to stay, because other clients have to be * informed about the new exercise (and they will not have the MODIFY event) */ if ( !linkNot.some( exerciseKey => cache.resolve(exerciseKey, 'id') === newExercise.id ) ) { cache.link(...params, [ ...linkNot, { __typename: 'ExerciseType', id: newExercise.id }, ]) } break } case 'DELETE': { const linkNot = cache.resolve(...params) || [] Loading Loading
graphql/urql/worker/cacheConsumer.ts +21 −7 Original line number Diff line number Diff line Loading @@ -594,7 +594,6 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ }) }, exercisesSubscription({ exercisesSubscription }, _args, cache) { console.log('exercisesSubscription', exercisesSubscription) const { exercise: newExercise, eventType } = exercisesSubscription || {} if (!newExercise || !eventType) { return Loading @@ -602,18 +601,33 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ const params = ['Query', 'exercises'] as const switch (eventType) { case 'CREATE': { case 'CREATE': { const linkNot = cache.resolve(...params) || [] if (!Array.isArray(linkNot)) { throw Error('Generic typing error, look up exercisesSub') } /* * only add the exercise if it does not exist; * this can happen when the exercise is created: * 1. the MODIFY event is sent because the creator is assigned as an instructor * 2. the CREATE event is sent because the exercise is created * * the CREATE event has to stay, because other clients have to be * informed about the new exercise (and they will not have the MODIFY event) */ if ( !linkNot.some( exerciseKey => cache.resolve(exerciseKey, 'id') === newExercise.id ) ) { cache.link(...params, [ ...linkNot, { __typename: 'ExerciseType', id: newExercise.id }, ]) } break } case 'DELETE': { const linkNot = cache.resolve(...params) || [] Loading