question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unauthorized error with @connection

See original GitHub issue

Describe the bug I have received a permission error from AppSync on @connection fields.

Amplify CLI Version 4.23.3 (latest)

To Reproduce

Schema example

type Customer
  @searchable
  @key(fields: ["id"])
  @model
  @auth(rules: [{ allow: owner, ownerField: "id", operations: [read, create, update] }]) {
  id: ID!
  name: String
  customerParameters: CustomerParameters @connection(fields: ["id"])
  createdAt: AWSDateTime
  updatedAt: AWSDateTime
}

type CustomerParameters
  @key(fields: ["id"])
  @model
  @auth(rules: [{ allow: owner, ownerField: "id", operations: [read, create, update] }]) {
  id: ID!
  value: String!
  customer: Customer @connection(fields: ["id"])
}

Query

query query {
  getCustomer(id:"123") {
    id
    name
    customerParameters {
      id
    }
  }
}

Response

Version 4.23.3 (latest) it’s not working

{
  "data": {
    "getCustomer": {
      "id": "123",
      "name": "My Customer",
      "customerParameters": null
    }
  },
  "errors": [
    {
      "path": [
        "getCustomer",
        "customerParameters"
      ],
      "data": null,
      "errorType": "Unauthorized",
      "errorInfo": null,
      "locations": [
        {
          "line": 5,
          "column": 5,
          "sourceName": null
        }
      ],
      "message": "Not Authorized to access customerParameters on type Customer"
    }
  ]
}

Expected behavior

Version 4.22.0 it’s working

{
  "data": {
    "getCustomer": {
      "id": "123",
      "name": "Customer Name"
      "customerParameters": null
    }
  }
}

Desktop (please complete the following information):

The build is being done at Amplify Console.

Additional context

My model schema is big, so I extracted just one piece of it.

Edit.: Amplify version

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
SwaySwaycommented, Aug 14, 2020

@mogarick The fix is included in cli v4.27.2+

2reactions
dtelarolicommented, Jul 27, 2020

@blbigelow You should change something in the model, because, strangely, the amplify does not apply changes if you don’t change the model. I lost too much time to discover this behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

401 Unauthorized - HTTP - MDN Web Docs
The HyperText Transfer Protocol (HTTP) 401 Unauthorized response status code indicates that the client request has not been completed ...
Read more >
401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error indicates that the server's request was not verified because it lacks valid authentication credentials for the target ...
Read more >
How to Fix a 401 Unauthorized Error - Lifewire
The 401 Unauthorized error is an HTTP status code that means the page you were trying to access cannot be loaded until you...
Read more >
How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >
401 Unauthorized Error: What It Is and How to Fix It
The most common cause of a 401 Unauthorized Error is an incorrect URL. As discussed before, web servers will disallow access to improper ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found