Graphcool / graphcool-framework

Apache License 2.0
1.78k stars 130 forks source link

Model type creation without input parameters results in an 'insufficient permissions' error #448

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by martijnvdbrug Friday Jan 05, 2018 at 09:42 GMT Originally opened as https://github.com/graphcool/prisma/issues/1511


Current behavior

Creating a new model type without input scalar fields always returns 'insufficient permissions' error.

Reproduction

Create a graphcool service with the following model and permissions:

graphcool.yml

types: ./types.graphql

permissions:

  # TEST
  - operation: Test.read
    authenticated: false
    query: testExists.graphql

  - operation: Test.create
    authenticated: false
    query: testExists.graphql

  - operation: Test.update
    authenticated: false

  - operation: Test.delete
    authenticated: false

rootTokens:
  - gateway

types.graphql

type Test @model {

    id: ID! @isUnique
    createdAt: DateTime!
    updatedAt: DateTime!

    name: String
}

testExists.graphql

query test {
  SomeTestExists
}

Executing the following query results in 'insufficient permissions':

mutation{
  createTest{
    name
  }
}

Executing this query successfully creates a Test type:

mutation{
  createTest(name:"test"){
    name
  }
}

Expected behavior?

Both queries should result in a model type Test being created.

martijnvdbrug commented 6 years ago

This seems like a similar issue: https://www.graph.cool/docs/reference/auth/authorization/important-notes-aej3ne1eez/