Skip to content

Instantly share code, notes, and snippets.

@sdanko
Created November 26, 2021 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdanko/11ad379716b83cd9b4eb764949d794f7 to your computer and use it in GitHub Desktop.
Save sdanko/11ad379716b83cd9b4eb764949d794f7 to your computer and use it in GitHub Desktop.
React Apollo: Using Subscriptions
const messagesQuery = gql`
query MessagesQuery {
messages {
id
from
text
}
}
`;
const messageAddedSubscription = gql`
subscription {
messageAdded {
id
from
text
}
}
`;
const addMessageMutation = gql`
mutation AddMessageMutation($input: MessageInput!) {
message: addMessage(input: $input) {
id
from
text
}
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment