amplify-js: DataStore - Validation error of type MissingFieldArgument: Missing field argument owner for Subscription and Sync
Describe the bug When using the below schema
type Recipe
@model
@auth(rules: [
{ allow: owner, provider: oidc, identityClaim: "sub" }
]) {
id: ID!
name: String
description: String
ingredients: [Ingredient] @connection(keyName: "byRecipe", fields: ["id"])
sourceType: String
source: Source @connection
}
I get the below error:
DataStore - subscriptionError Connection failed: {"errors":[{"message":"Validation error of type MissingFieldArgument: Missing field argument owner @ 'onCreateRecipe'"}]}
DataStore - Sync error Connection failed: {"errors":[{"message":"Validation error of type MissingFieldArgument: Missing field argument owner @ 'onCreateRecipe'"}]}
The record is created locally, but does not push. Because it cannot push, also cannot get
To Reproduce
- Create an API with an OIDC auth +
AUTOMERGEconflict resolution - Run
node amplify/scripts/amplify-modelgen.js+amplify push - Launch the application and obverse the console
Expected behavior No error in console, the records push and pull correctly.
Code Snippet
DataStore.query(Recipe) <- Recipe is imported from the generated index.d.ts
What is Configured? If applicable, please provide what is configured for Amplify CLI:
- Which steps did you follow via Amplify CLI when configuring your resources.
- See reproduction steps above
- Which resources do you have configured?
- If applicable, please provide your
aws-exportsfile:
const awsmobile = { "aws_project_region": "us-east-1", "aws_appsync_graphqlEndpoint": "https://<address-of-endpoint>.appsync-api.us-east-1.amazonaws.com/graphql", "aws_appsync_region": "us-east-1", "aws_appsync_authenticationType": "OPENID_CONNECT" };- If applicable, please provide your manual configuration example:
{ Auth:{ identityPoolId: 'us-east-1:<id-of-pool>', region: 'us-east-1', refreshHandlers: { '<address-of-saml>': <refresh-function> } } } - If applicable, please provide your
Environment
npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages
System:
OS: Linux 4.19 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Memory: 18.16 GB / 24.92 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.15.3 - /usr/bin/node
Yarn: 1.22.10 - /usr/bin/yarn
npm: 6.14.10 - /usr/bin/npm
npmPackages:
@angular-devkit/build-angular: ^0.1100.5 => 0.1100.5
@angular/cli: ^11.0.5 => 11.0.5
@angular/common: ^11.0.5 => 11.0.5
@angular/compiler: ^11.0.5 => 11.0.5
@angular/compiler-cli: ^11.0.5 => 11.0.5
@angular/core: ^11.0.5 => 11.0.5
@angular/forms: ^11.0.5 => 11.0.5
@angular/language-service: ^11.0.5 => 11.0.5
@angular/localize: ^11.0.5 => 11.0.5
@angular/platform-browser: ^11.0.5 => 11.0.5
@angular/platform-browser-dynamic: ^11.0.5 => 11.0.5
@angular/router: ^11.0.5 => 11.0.5
@auth0/auth0-spa-js: ^1.13.5 => 1.13.5
@aws-amplify/analytics: ^3.3.11 => 3.3.11
@aws-amplify/cache: ^3.1.41 => 3.1.41
@aws-amplify/datastore: ^2.9.2 => 2.9.2
@aws-amplify/interactions: ^3.3.16 => 3.3.16
@aws-amplify/storage: ^3.3.16 => 3.3.16
@aws-amplify/xr: ^2.2.16 => 2.2.16
@capacitor/cli: ^2.4.5 => 2.4.5
@capacitor/core: ^2.4.5 => 2.4.5
@ionic-native/core: ^5.30.0 => 5.30.0
@ionic-native/splash-screen: ^5.30.0 => 5.30.0
@ionic-native/status-bar: ^5.30.0 => 5.30.0
@ionic/angular: ^5.5.2 => 5.5.2
@okta/okta-angular: ^3.0.1 => 3.0.1
@types/jasmine: ^3.6.2 => 3.6.2
@types/jasminewd2: ~2.0.3 => 2.0.8
@types/jest: ^26.0.19 => 26.0.19
@types/mocha: ^8.2.0 => 8.2.0
@types/node: ^14.14.14 => 14.14.14
aws-amplify-angular: ^5.0.42 => 5.0.42
buffer: ^6.0.3 => 6.0.3
codelyzer: ^6.0.1 => 6.0.1
core-js: ^3.8.1 => 3.8.1
ini: ^1.3.8 => 1.3.8
inquirer: ^7.3.3 => 7.3.3
jasmine-core: ^3.6.0 => 3.6.0
jest: ^26.6.3 => 26.6.3
karma: ^5.2.3 => 5.2.3
karma-chrome-launcher: ^3.1.0 => 3.1.0
karma-coverage: ^2.0.3 => 2.0.3
karma-jasmine-html-reporter: ^1.5.4 => 1.5.4
protractor: ^7.0.0 => 7.0.0
puppeteer: ^5.5.0 => 5.5.0
rxjs: ^6.6.3 => 6.6.3
tslib: ^2.0.3 => 2.0.3
tslint: ~6.1.0 => 6.1.3
typescript: ^4.0.5 => 4.0.5
zone.js: ^0.10.2 => 0.10.3
npmGlobalPackages:
@angular/cli: 11.0.5
@aws-amplify/cli: 4.40.1
@ionic/cli: 6.12.3
flag: 4.4.0
ionic: 5.4.16
native-run: 1.3.0
npm: 6.14.10
yarn: 1.22.10
Smartphone (please complete the following information):
- Device: Windows Machine
- OS: Windows
- Browser: Firefox + Chrome
- Version: 84 / 87
Additional context Cognito authentication looks correct (no auth errors messages) and JWT token can authenticate through the AppSync console, so my best guess is that this is something to do with the schema. Happy to provide any other insights.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (10 by maintainers)
@amhinson - happy to ping you - will be later today but we can sync there
Ah ok! I’ve got a few observations and suggestions:
In most cases, you should only need to call
Amplify.configure(...)once. Calling it additionally from the other categories can lead to unexpected behavior due to the singleton nature of most of the categories. I would suggest combining theaws-exportswith your customAuthconfiguration like this:Additionally, I see in your
package.jsonyou have individual modules imported instead of justaws-amplify. This probably isn’t causing any problems now because you’re using the latest version of all of them, but our recommendation is to just simply useaws-amplifyand let the bundler handle any treeshaking needed.Ok thanks for looking into that! Would you be able to share the logs from
Amplify.Logger.LOG_LEVEL = 'DEBUG'? That will give a better idea of what is going on. Be sure to remove any sensitive data as needed.@getglad Just curious, are you authenticated when you try to create the item?
Also, could you share the code for creating the item with
DataStore.save(...)?