Eunovo / superbackend

Create your database and service layer from GraphQL types
MIT License
4 stars 0 forks source link

What happens when two or more 'create' rules are defined on the same field? #10

Open Eunovo opened 3 years ago

Eunovo commented 3 years ago

We can declare an access rule on a particular role like this

"""@model"""
type Test {
  """
  @allowOn('USER', 'allow1', 'create')
  """
  test: String
}

Which forces the all create inputs for any USER to set test = 'allow1'. This way, USER can create a Test with the test field set to anything other than allow1.

What happens when two or more create rules are defined on the same field?

  """
  @allowOn('USER', 'allow1', 'create')
  @allowOn('USER', 'allow2', 'create')
  """
  test: String

Currently, the test field will always be set to allow2.

This creates no problems for 'read' and 'delete' operations because they do not save data. Forcing the filters work for queries but maybe we shouldn't force inputs.