Skip to content

Using cache.updateQuery() for a Subscription causes an infinite loop #2388

Answered by ajenkins
ajenkins asked this question in Q&A
Discussion options

You must be logged in to vote

I was able to fix this by using the solution suggested in #2257 . Here's my final code for anyone interested:

// GetMessages.js

const GET_MESSAGES = (operationType) => `
  ${operationType} GetMessages($myId: uuid!, $theirId: uuid!) {
    messages(
      where: {
        _or: [
          { from: { _eq: $myId }, to: { _eq: $theirId } }
          { from: { _eq: $theirId }, to: { _eq: $myId } }
        ]
      }
      order_by: { sent_at: asc }
    ) {
      id
      message
      from
      to
      sent_at
    }
  }
`;

export default GET_MESSAGES;
// urql-client.js

const normalizedCacheExhange = cacheExchange({
  keys: {
    user_connections: (data) => data.user_id_smaller + data.user_id…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gopeter
Comment options

@ajenkins
Comment options

@zwily
Comment options

Answer selected by ajenkins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants