laravel-graphql icon indicating copy to clipboard operation
laravel-graphql copied to clipboard

Detect impossible to resolve validation rules

Open spawnia opened this issue 6 years ago • 0 comments

I found that validating for circular references within Input Objects is an ongoing issue within the specification project: https://github.com/facebook/graphql/issues/189

input Something {
  name: String
  somethingElse: Something!
}

I suppose we could take it for granted that illegal Input Object definitions will eventually be caught by the schema validation. Lee Byron already stated that he deems it necessary, the question here is just when that will happen.

However, i think we have to consider this from the perspective of laravel as well, since we have an additional layer of validation on top. The following example would be an Input Object definition with Laravel-based validation that cannot possibly work:

class ExampleValidationInputObject extends BaseType
{
    protected $inputObject = true;

    public function fields()
    {
        return [
            'self' => [
                'name' => 'self',
                'type' => GraphQL::type('ExampleValidationInputObject'),
                'rules' => ['required']
            ],
        ];
    }
}

spawnia avatar May 09 '18 12:05 spawnia