How to create a mutation after being authorized? <...
# prisma-whats-new
p
i
Did you add the Authorization header ? { Authorization : 'Bearer '+token }
p
Yes
f
If you go under Permissions and POST - the create field .. what does the permissions say?
Copy code
const client = new GraphQLClient('<https://api.graph.cool/simple/v1/backpack-blue>', {
  headers: {
    Authorization: 'Bearer bunchOFlettersKey',
  },
})
p
Crossed out
permissions: []
f
Probable have to enable that for a user or everyone as a test
p
f
doing it via cli?
p
They are not active when you click
cli
f
https://github.com/graphcool/framework/tree/master/cli/packages/graphcool-cli The readme has a sample .. ill see if I can find a better one
p
permissions: - operation: "*" ?
f
Yeah, then specify operations/schema .. trying to dig up some good code from our library
p
excellent, I'll try)
f
yeah its all based around the yml updating the permissions .. you can verify in the console ..
I use a unit test .. basically a queyr that should work and a query that shouldnt work to validate
p
Thanks 😃
Now
Copy code
permissions:
  - operation: User.read
  - operation: User.create
    authenticated: true
  - operation: User.update
    authenticated: true
  - operation: User.delete
    authenticated: true
  - operation: Post.read
  - operation: Post.create
    authenticated: true
  - operation: Post.update
    authenticated: true
  - operation: Post.delete
    authenticated: true
  - operation: Comment.read
  - operation: Comment.create
    authenticated: true
  - operation: Comment.update
    authenticated: true
  - operation: Comment.delete
    authenticated: true
"code": 3032, "message": "The field 'author' on type 'Post' is required. Performing this mutation would violate the constraint" Does the author fill in the field automatically?
f
author is set to a required field author! .. and it looks like the relation @StudioPosts doesnt exist?
p
simplified the task 😃 https://www.graph.cool/forum/t/no-connect-permissions/1940 I need example simple todo-list with authorization
🦜 1
f
Did you add Todo.create? and it shows Everyone in console
p
All earned thanks 😃