amplify-js: Amplify owner:ID using @auth does not register

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

GraphQL API, DataStore

Amplify Categories

auth, api

Environment information

# Put output below this line


Describe the bug

When using @auth(rules: [{ allow: owner, provider: userPools, ownerField: “owner” }]), even without the auth the owner field does not get initialized for some models.

Schema: image

There is not much difference in Message and Item

API results image

owner is getting populated for Message but not for Item

Expected behavior

owner should be populated for all tables.

Reproduction steps

Run the schema provided

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

/* eslint-disable */ // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = { “aws_project_region”: “ap-southeast-2”, “aws_cognito_identity_pool_id”: “XXXXXXXXXXXXXXXXXXXXXXXXXXX”, “aws_cognito_region”: “ap-southeast-2”, “aws_user_pools_id”: “XXXXXXXXXXXXXXXXXXXXXX”, “aws_user_pools_web_client_id”: “XXXXXXXXXXXXX”, “oauth”: {}, “aws_cognito_username_attributes”: [ “EMAIL” ], “aws_cognito_social_providers”: [], “aws_cognito_signup_attributes”: [ “EMAIL”, “ADDRESS”, “BIRTHDATE”, “NAME”, “PHONE_NUMBER”, “PREFERRED_USERNAME” ], “aws_cognito_mfa_configuration”: “OFF”, “aws_cognito_mfa_types”: [ “SMS” ], “aws_cognito_password_protection_settings”: { “passwordPolicyMinLength”: 8, “passwordPolicyCharacters”: [ “REQUIRES_LOWERCASE”, “REQUIRES_NUMBERS”, “REQUIRES_UPPERCASE” ] }, “aws_cognito_verification_mechanisms”: [ “EMAIL” ], “aws_user_files_s3_bucket”: “XXXXXXX-storage-devXXXXXXXXXXXXXXXXdev”, “aws_user_files_s3_bucket_region”: “ap-southeast-2”, “aws_appsync_graphqlEndpoint”: “http://XXXXXXXXXXXXX/graphql”, “aws_appsync_region”: “ap-southeast-2”, “aws_appsync_authenticationType”: “AMAZON_COGNITO_USER_POOLS”, “aws_appsync_apiKey”: “XXXXXXXXXXXXXXXXXX”, “aws_appsync_dangerously_connect_to_http_endpoint_for_testing”: true };

export default awsmobile;

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 2 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Hi! Thanks for raising this issue. This probably wouldn’t fix your issue but if you’re using Cognito User Pools and naming your owner field “owner”, you can remove the provider: userPools and ownerField: "owner" part of your schema. So, all you need is { allow: owner }.

Otherwise, I would just separate this mutation into two separate mutations, one for createMessage and one for createItem and see if the owner field is then populated in both results.