Loading graphql/urql/worker/cacheConsumer.ts +7 −51 Original line number Diff line number Diff line Loading @@ -603,29 +603,15 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ switch (eventType) { 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': { Loading @@ -646,37 +632,7 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ break } case 'MODIFY': { /* * if the exercise already exists, write the fragment * (the exercise state or config was modified) */ /* * if the exercise does not exist, add it as a new exercise * (the user was assigned to a team) */ // TODO: what if the team was unassigned? currently, no event from BE is sent const exercisesQuery = cache.resolve(...params) || [] if (!Array.isArray(exercisesQuery)) { throw Error('Generic typing error, look up exercisesSub') } if ( exercisesQuery.some( exerciseKey => cache.resolve(exerciseKey, 'id') === newExercise.id ) ) { cache.writeFragment(Exercise, newExercise) } else { cache.link(...params, [ ...exercisesQuery, { __typename: 'ExerciseType', id: newExercise.id }, ]) } break } case '%future added value': Loading Loading
graphql/urql/worker/cacheConsumer.ts +7 −51 Original line number Diff line number Diff line Loading @@ -603,29 +603,15 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ switch (eventType) { 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': { Loading @@ -646,37 +632,7 @@ const cache: Exchange = offlineExchange<GraphCacheConfig>({ break } case 'MODIFY': { /* * if the exercise already exists, write the fragment * (the exercise state or config was modified) */ /* * if the exercise does not exist, add it as a new exercise * (the user was assigned to a team) */ // TODO: what if the team was unassigned? currently, no event from BE is sent const exercisesQuery = cache.resolve(...params) || [] if (!Array.isArray(exercisesQuery)) { throw Error('Generic typing error, look up exercisesSub') } if ( exercisesQuery.some( exerciseKey => cache.resolve(exerciseKey, 'id') === newExercise.id ) ) { cache.writeFragment(Exercise, newExercise) } else { cache.link(...params, [ ...exercisesQuery, { __typename: 'ExerciseType', id: newExercise.id }, ]) } break } case '%future added value': Loading