Can someone help me with permission query that che...
# prisma-whats-new
m
Can someone help me with permission query that checks for user role? I'm using the same perm query for Create/Update/Delete, but only Delete works, Create/Update both fail with insufficient permission. Query is this:
Copy code
query ($user_id: ID!) {
  SomeUserExists(
    filter: {
      id: $user_id,
      role: ADMIN
    }
  )
}
n
how does the create mutation look like that doesn't work? what's the error message?
m
Uncaught (in promise) Error: GraphQL error: Insufficient permissions for this mutation at new ApolloError (bundle.js:3527) at bundle.js:1707 at <anonymous>
n
can you please log the complete apollo error and not only the error message
m
Copy code
const createPage = gql`mutation createPage($bookId: ID!) {
  createPage(bookId: $bookId) {
    id
  }
}
`
n
I believe
this.props.data.error
contains a full error object
m
Copy code
{
  "data": {
    "createPage": null
  },
  "errors": [
    {
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createPage"
      ],
      "code": 3008,
      "message": "Insufficient permissions for this mutation",
      "requestId": "cj54c92covesy0170n3g08n7d"
    }
  ]
}
n
ok
could you please send me the request as cURL in a PM?
oh wait
not needed
you need to include another field in the
createPage
mutation
so the permission is registered
the create permission is not registered for the relational field
bookId
m
But I didn't touch any Relations permissions
everyone can connect/disconnect
n
yes. for example, this will work
Copy code
const createPage = gql`mutation createPage($bookId: ID!) {
  createPage(bookId: $bookId, dummy: "hi") {
    id
  }
}
`
if the create permission is registered for the
dummy
field
m
I see what you mean.... this Page type actually doesn't have any value fields, it's all relations
n
this is how it currently works. you can add a
dummy
field to the
Page
type then
m
but where you are coming from makes sense
yeah I will do thta
you should mention this in the docs
n
yea good point