-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use Set
as property in GraphQL argument input object
#394
Comments
We've discussed this issue and we'd like to give an update here. In the meantime, we think that having a constructor with arguments would work with the current implementation. This might be problematic if you're binding to a JPA entity - but we also think that binding directly to an entity is a bit strange in the first place (you might want to use specific objects for your API). For the time being we're not sure about the solution - we might improve the binding process or just document this as a limitation. Can you try creating a constructor with arguments and see if that solves the issue? |
I've been seeing a similar issue whereby we're trying to bind to an entity using the constructor (kotlin). This is failing as GraphQL creates a List and the Entity is expecting a Set. After debugging the code, I found that the argument binder is creating a new list rather than a set. This is the line in question: https://github.com/spring-projects/spring-graphql/blob/main/spring-graphql/src/main/java/org/springframework/graphql/data/GraphQlArgumentBinder.java#L212 Instead of passing in the rawCollection when binding, I'm thinking we should pass in the constructor type instead, using this method:
Stack Trace
|
Thanks @JBodkin-Amphora , I've created #485 to solve this. Sorry for the late reply. This should now work for constructor binding. In @AndriuQuesada 's case, constructor binding is not being used and we're instead using the java bean property notation to bind to an obejct. The Spring Framework reference documentation for binding nested properties only refers to naturally ordered collections but does not mention When binding to a set, the property accessor tries to access the element and, unlike other Collections, does not try to "auto-grow" the collection. Maybe this is something that could be taken care of in Spring Framework. We'll need to discuss that further in the team. Note that the Spring Boot |
This might be fixed by #516 |
I've added a test that confirms this is fixed by #516, which I will commit shortly. This will therefore be available in the upcoming 1.1 release. |
Set
as property for GraphQL argument input object
Set
as property for GraphQL argument input objectSet
as property in GraphQL argument input object
Hello,
I have a ManyToMany relationship between two entities Team and Job.
The Team class contains the next code
Querying the Teams with their jobs using graphql works perfectly, but when doing a mutation like the next
The next error on the server is raised:
The text was updated successfully, but these errors were encountered: