How do I filter a subscription (or a query) by a s...
# prisma-whats-new
c
How do I filter a subscription (or a query) by a specific relationship id? I’ve got the following inside my `subscribeToMore()`:``` document: gql` subscription { Donation( filter: { mutation_in: [CREATED, UPDATED, DELETED] node: { campaign: { id: this.props.campaignId } } } ) { mutation node { id amount email isPaid } previousValues { id } } } `,``` but
this.props.campaignId
is not valid inside the
gql
can I just break the interpolation with
${this.props.campaignId}
?
…this doesn’t work…
a
try this:
id: “${this.props.campaignId}”
Notice the
"
d
Assuming you are using Apollo, you will need to pass a variable into the subscription query using the second parameter of the graphql HOC, which can provide a function for options that takes props as its argument and returns an options object that can include your variable
c
I went with `dankent`‘s suggestion and broke out the
gql
into a const, passing the
$campaignId
there