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

ClosureDataFetchingEnvironment's fetchArguments is always empty

Open jamesdh opened this issue 4 years ago • 2 comments

When defining a custom property/field, the docs say we can use the provided fetchArguments for retrieving the fetch options or the list of join properties. However, it's perpetually empty, and hence we lose out on the automatic join operations.

Oddly enough, the test for this functionality appears to actually confirm this:

https://github.com/grails/gorm-graphql/blob/5149504d3f31a588d6a660d20899030d30329708/examples/grails-test-app/src/integration-test/groovy/grails/test/app/TagIntegrationSpec.groovy#L110-L130

If you look at the second query, you can see it queried for more properties than were specified in the original query, and if you debug the actual test, you'll see that env.fetchArguments is always an empty Map. Hence the test is incorrect, given the actually expected behavior.

It appears this is the root cause:

https://github.com/grails/gorm-graphql/blob/5149504d3f31a588d6a660d20899030d30329708/core/src/main/groovy/org/grails/gorm/graphql/entity/EntityFetchOptions.java#L213-L215

So either that is intended (and arguably not very useful) and the docs are misleading, or the docs are correct and this is actually not functioning as intended.

jamesdh avatar Jan 26 '21 19:01 jamesdh

Took another look at this tonight and I'm not sure what I was doing wrong earlier but I'm seeing the fetchArguments correctly now when debugging. Closing for now at least.

jamesdh avatar Jan 27 '21 02:01 jamesdh

Reopening this as it appears that fetchArguments is always null when using the property dsl to modify a current properties dataFetcher, but appears to be working correctly when using the add dsl.

jamesdh avatar Jan 27 '21 16:01 jamesdh