question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subscription not working when condition input

See original GitHub issue

Schema & Subscription

type HubFleet @model
@key(fields: [ "PK", "SK" ])
@key(name: "GSI1", fields: [ "GSI1","GSISK1" ], queryField: "GSI1")
@key(name: "GSI2", fields: [ "GSI2","GSISK2" ], queryField: "GSI2")
@key(name: "GSI3", fields: [ "GSI3","GSISK3" ], queryField: "GSI3")
{
	id: ID!
	PK: String!
	SK: String!
	GSI1: String
	GSISK1: String
	GSI2: String
	GSISK2: String
	GSI3: String
	GSISK3: String
}
input ModelStringKeyConditionInput {
	eq: String
	le: String
	lt: String
	ge: String
	gt: String
	between: [String]
	beginsWith: String
}
type Subscription {
	subscribeCreateHubFleetByOrg(GSI1:String!,GSISK1:ModelStringKeyConditionInput): HubFleet @aws_subscribe(mutations: ["createHubFleet"])
	subscribeUpdateHubFleetByOrg(GSI1:String!,GSISK1:ModelStringKeyConditionInput): HubFleet @aws_subscribe(mutations: ["updateHubFleet"])
	subscribeDeleteHubFleetByOrg(GSI1:String!,GSISK1:ModelStringKeyConditionInput): HubFleet @aws_subscribe(mutations: ["deleteHubFleet"])
}

subscription query

export const subscribeCreateHubFleetByOrg = /* GraphQL */ `
  subscription SubscribeCreateHubFleetByOrg(
    $GSI1: String!
    $GSISK1: ModelStringKeyConditionInput
  ) {
    subscribeCreateHubFleetByOrg(GSI1: $GSI1, GSISK1: $GSISK1) {
      id
      PK
      SK
      GSI1
      GSISK1
      GSI2
      GSISK2
      GSI3
      GSISK3
    }
}

using it in react app

import { subscribeCreateHubFleetByOrg } from './graphql/subscriptions';
import gql from 'graphql-tag';
import { useSubscription } from 'react-apollo';
const CUSTOM_ADD_DATA_SUBSCRIPTION = gql`${subscribeCreateHubFleetByOrg}`;
useSubscription(CUSTOM_ADD_DATA_SUBSCRIPTION, {
	variables: { GSI1:"VALUE", GSISK1: { beginsWith: 'ORG#' } },
	onSubscriptionData: ({ client, subscriptionData }) => { debugger; handleUpdateTodo(client, subscriptionData) }
});

when i use with conditional input then it’s not works but when i use it without conditional input then it’s works

useSubscription(CUSTOM_ADD_DATA_SUBSCRIPTION, {
	variables: { GSI1:"VALUE"},
	onSubscriptionData: ({ client, subscriptionData }) => { debugger; handleUpdateTodo(client, subscriptionData) }
});

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ashika01commented, Oct 9, 2020

@lochawala Gotcha. I will try to reproduce this tomorrow.

0reactions
github-actions[bot]commented, May 24, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subscribe not being triggered when the subject values changes
log("input value ", data); });. Service is receiving new value but the subscription in component B is not being triggered.. what am I...
Read more >
Subscriptions - Apollo GraphQL Docs
Like queries, subscriptions enable you to fetch data. Unlike queries, subscriptions are long-lasting operations that can change their result over time. They can ......
Read more >
GraphQL specification
If a GraphQL server expects a scalar type as input to an argument, coercion is observable and the rules must be well defined....
Read more >
Using CloudWatch Logs subscription filters
You can use a subscription filter with Kinesis, Lambda, or Kinesis Data Firehose. Logs that are sent to a receiving service through a...
Read more >
6 Ways to Unsubscribe from Observables in Angular
If a subscription is not closed the function callback attached to it will be continuously called, this poses a huge memory leak and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found