amplify-js: onCreate subscription returns null through `aws-amplify` API, but not through AppSync
Before opening, please confirm:
- I have searched for duplicate or closed issues and discussions.
- I have read the guide for submitting bug reports.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
JavaScript Framework
Not applicable
Amplify APIs
GraphQL API
Amplify Categories
api
Environment information
# Put output below this line
System:
OS: macOS 11.5.2
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 21.10 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.0.0 - ~/.nvm/versions/node/v16.0.0/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 7.19.0 - ~/.nvm/versions/node/v16.0.0/bin/npm
Watchman: 2021.06.07.00 - /usr/local/bin/watchman
Browsers:
Chrome: 92.0.4515.159
Edge: 92.0.902.78
Firefox: 84.0.2
Safari: 14.1.2
npmPackages:
@creativelayer/chalk-icons: ^1.1.2 => 1.1.2
@creativelayer/chalk-ui: ^1.36.0 => 1.36.1
@types/jest: ^26.0.24 => 26.0.24
@typescript-eslint/eslint-plugin: ^4.29.3 => 4.29.3
@typescript-eslint/parser: ^4.29.3 => 4.29.3
@vitejs/plugin-vue: ^1.4.0 => 1.4.0
@vue/compiler-sfc: ^3.2.4 => 3.2.4
@vue/eslint-config-standard: ^6.1.0 => 6.1.0
@vue/eslint-config-typescript: ^7.0.0 => 7.0.0
@vue/test-utils: ^2.0.0-rc.12 => 2.0.0-rc.12
@xstate/vue: ^0.8.0 => 0.8.0
autoprefixer: ^10.3.2 => 10.3.2
aws-amplify: ^4.2.4 => 4.2.4
buffer: ^6.0.3 => 6.0.3 (4.9.2)
cypress: ^8.3.0 => 8.3.0
dynamic-import-polyfill: ^0.1.1 => 0.1.1
eslint: ^7.32.0 => 7.32.0
eslint-plugin-cypress: ^2.11.3 => 2.11.3
eslint-plugin-import: ^2.24.1 => 2.24.1
eslint-plugin-jest: ^24.4.0 => 24.4.0
eslint-plugin-vue: ^7.16.0 => 7.16.0
jest: ^26.6.3 => 26.6.3
mockdate: ^3.0.5 => 3.0.5
postcss: ^8.3.6 => 8.3.6
tailwindcss: ^2.2.7 => 2.2.7
ts-jest: ^26.5.5 => 26.5.6
typescript: ^4.3.5 => 4.3.5
vite: ^2.5.0 => 2.5.0
vue: ^3.2.4 => 3.2.4
vue-jest: ^5.0.0-alpha.10 => 5.0.0-alpha.10
vue-loader: ^16.5.0 => 16.5.0
vue-router: ^4.0.11 => 4.0.11
vue-router-mock: 0.0.3 => 0.0.3
xstate: ^4.23.1 => 4.23.1
npmGlobalPackages:
@aws-amplify/cli: 5.2.1
np: 7.5.0
npm: 7.19.0
Describe the bug
When subscribing to a subscription with the graphqlOperation, and not specifying any variables, the returned data is always null, whereas subscribing in AppSync to the same thing without variables does actually yield the proper result.
Expected behavior
To be able to subscribe without variables and still get data returned.
Reproduction steps
Subscribe to something like onCreateTodo without any parameters, this should fire every time a todo is created, regardless of condition.
In AppSyn the result will be correct, in Amplify it won’t:
const subscription = API.graphql(
graphqlOperation(subscriptions.onCreateTodo)
).subscribe({
next: (data) => console.log(data),
error: error => console.warn(error),
})
data will be data: { onCreateBusiness: null } through API.graphql
Code Snippet
const subscription = API.graphql(
graphqlOperation(subscriptions.onCreateTodo)
).subscribe({
next: (data) => console.log(data),
error: error => console.warn(error),
})
Log output
// Put your logs below this line
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (11 by maintainers)
@chrisbonifacio Okay that seems to work now indeed, that’s good!
I think those were required to generate the proper types with
codegen. I’m actually in the process of moving the whole project over to TS so hopefully that will remedy that problem.I’ll ping you when that’s done and then we can explore this further. Appreciate the help!
Sure thing!
Here’s the subscription:
And the mutation:
Schema:
Custom subscription:
Now that I paste this… It’s the custom subscription, isn’t it? Regardless though, AppSync should then also not be able to subscribe without an ID, they should use them same schema, mutations, and subscriptions, no?