Adding @auth directive breaks amplify push
See original GitHub issueDescribe the bug
Whenever I add @auth
to one of my API models, I get a Cannot read property 'fields' of undefined
exception when running amplify push
. I do have Cognito authentication set up with my app and that works fine.
Amplify CLI Version 4.22.0
To Reproduce
Adding @auth
to this model gives me the error:
type UserAccount
@model
@key(
name: "accountsByUser"
fields: ["cognitoUserID"]
queryField: "accountsByUser"
)
@auth(rules: [{ allow: owner }]) {
id: ID!
cognitoUserID: String!
institutionName: String!
institutionID: String!
accessKey: String!
}
Expected behavior
Expected @auth
to work fine.
Screenshots
Cannot read property 'fields' of undefined
An error occurred during the push operation: Cannot read property 'fields' of undefined
Desktop (please complete the following information):
- OS: Mac
- Node Version: 14.2
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Reference - Feature Flags - AWS Amplify Docs
When a feature flag is added to the Amplify CLI it will be mentioned in the release notes and also this page will...
Read more >AWS Amplify Features | Front-End Web & Mobile
Amplify Studio provides a visual interface for modeling data, adding authentication, authorization and managing users and groups. As you create backend ...
Read more >Offline-first made easy with GraphQL, Amplify DataStore and ...
First, we are going to create the GraphQL API to service Chatty chatroom. To create it, we will use the following command: amplify...
Read more >AWS-Amplify/Lobby - Gitter
After adding auth using the CLI, do I also need to create a user pool in ... try to run amplify push, it...
Read more >@aws-amplify/graphql-model-transformer - npm
This would create and configure a single query field post(id: ID!): Post and no mutation fields. @auth. Object types that are annotated with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@apiel51 I was not able to reproduce the issue with the provided schema, but thanks for the details that helped to locate the issue and you are right, the root cause is that
subscription
is not part of theschema
element which can happen as in @bever1337 's case whenschema
is manually defined, now I’m making a fix for @bever1337 's case so it will addsubscription
member even ifschema
is manually defined but does not have thesubscription
operations type added.@apiel51 could you provide some more details, do you have
schema
in your schema file defined? I want to make sure that we’re covering the grounds, but based on the stacktrace my fix will cover it. If after PR merge and release you can still reproduce it, feel free to reopen the issue.@bever1337 to add custom operations to
Query
orMutation
orSubscription
you don’t need to define theschema
element in the schema, GraphQL compilation in the CLI will handle that. So this piece is not needed:This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server
*-help
channels for those types of questions.