Skip to content

Multiple field and access #674

@Vincz

Description

@Vincz
Q A
Bug report? yes
Feature request? no
BC Break report? yes
Version/Branch 0.13.2

When using annotations, if we found a multiple relation with doctrine (OneToMany or ManyToMany), we generate a non null multiple (like: [Friends]!). It means that the field will always be an array (but it can be empty). So we have a Type::nonNull field.
If we have an access on this field, like @=isGranted() and we query for this field without being allowed, it will return a null value for the entire object instead of just for this fields itself (I haven't been able to really trace the problem, but I think it is in webonyx/graphql).

There is multiple ways to solve this problem.

  1. Generate nullable type instead of non nullable type
  2. Detect if we have an "access" on a field and if the field is "multiple", remove the non nullable
  3. Try to detect the case in the request handling and return an empty array instead of a null value

Personally, I would prefer the second one as if we have a field with an access, we are supposed to be able to return null for this field.

What do you think about this guys ?
ping @mcg-web @murtukov @akomm ?

I make a PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions