Comments (4)
@JimmyHurrah -- I suspect you've found a bug in the emulator. If I understand you correctly, the following needs to be changed:
- subscription resolver should always return the payload of the mutation
Could you explain in a little more detail, or provide code examples regarding the triggering of the subscription resolver?
As I understand things, its okay if the subscription resolver is triggered, it only matters that clients subscribing to these resolvers can receive the data after initiating a subscription via web socket.
from aws-utils.
@cbaron Your understanding of the problem is spot on. It does not really matter if the resolver is triggered as long as the response is from the mutation.
I guess the easiest way to reproduce this would be to have a mutation with a subscription where the subscription response mapping always returns null
Maybe a log from when I trigger a mutation will help.
I have a subscription called onMessage
which subscribes to a mutation createMessage
where the request mapping for the subscription only returns null
Heres the output from sending the mutation:
● start graphql
mutation createMessage($conversationid: ID!, $text: String!) {
createMessage(conversationid: $conversationid, text: $text) {
_id
text
__typename
}
}
● start Resolve: Mutation.createMessage [createMessage]
ℹ info Rendered Request:
{ version: '2017-02-28',
operation: 'Invoke',
payload:
{ type: 'Mutation',
field: 'createMessage',
args: { conversationid: '1', text: 'Test' },
source: {},
} }
ℹ info Dispatch to source { name: 'Resolvers', type: 'AWS_LAMBDA' }
Received payload {} {"type":"Mutation","field":"createMessage","args":{"conversationid":"1","text":"Test"},"source":{}}
ℹ info Rendered Response:
{ conversationid: '1',
author: '1',
createdAt: '2019-03-10T21:56:45.603Z',
text: 'Test',
_id: '1' }
● start Resolve: Subscription.onMessage [onMessage]
ℹ info Dispatch to source { name: 'Resolvers', type: 'AWS_LAMBDA' }
Received payload {} {"type":"Subscription","field":"onMessage","args":{"conversationid":"1","author":"1","createdAt":"2019-03-10T21:5
ℹ info Rendered Request: { authorized: true }
ℹ info Rendered Response: null
ℹ info publish
{ payload: { data: { onMessage: null } },
clientId: '1234567890',
topicId: '88f5b85f-7a40-491b-80d5-c0d3023de867' }
ℹ info client (1234567890) unsubscribed to : 88f5b85f-7a40-491b-80d5-c0d3023de867
ℹ info client disconnected to subscription server (1234567890)
from aws-utils.
Got it. That shouldn't be too hard to fix in the emulator. I will try to get to it this week. As always, you're welcome to put up a PR as well -- let me know if I can be of assistance.
Also, in the meantime, I think as a workaround you can follow the example laid out in in our unit tests.
Here is the serverless.yml which uses a "pass through" subscription resolver to return exactly the mutation:
dataSource: SubscriberPassthrough
type: Subscription
field: subscribeToPutQuoteRequest
request: subscribePassthrough-request.txt
response: result-response.txt
from aws-utils.
I tried looking into the subscription code before opening this issue but I couldn't really follow how the pubsub, mqtt and subscription server stuff worked together. I might give it another go later this week.
Thanks for the workaround, it works as expected 👍
from aws-utils.
Related Issues (20)
- Cannot find function config for function : undefined HOT 1
- Failure trying to run tests HOT 3
- ValueMapper: JavaString HOT 2
- Feature request: Aurora (RDS) Serverless support HOT 1
- AppSync Emulator - Support Condition Expressions
- AppSync Emulator - Support $context.stash
- appsync emulator resultItems mapping template example does not work in AWS
- [appsync-emulator-serverless] Does not respect multiple appsSync API's in config HOT 2
- AppSync Emulator - Support RegEx in string split
- Cannot Install on Windows HOT 1
- [appsync-emulator-serverless] Conflicting peer dependencies
- Bug with getting PID by port HOT 9
- Lambda datasource docker HOT 12
- Emulator does not throw error when AppSync does
- AppSync Emulator - AWSEmail and AWSURL HOT 1
- Incorrect string equality in VTL templates HOT 1
- Unable to Invoke lambda function HOT 2
- Mismatch between AWSJSON and AppSync
- Assertions within createSchema method prevent DynamoDB from being null HOT 1
- Incorrect $util.isNullOrEmpty check in appsynce-emulator HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-utils.