Open dricholm opened 5 days ago
Thank you for the detailed issue and analysis!
It took me some time to get into the issue, but I believe you are correct: there is an inconsistency between the place where react-admin puts the meta
value in the create
/update
call params, and the place where ra-data-graphql-simple expects it to be.
Would you like to open a PR to fix this issue? Thanks.
Thank you for the detailed issue and analysis!
It took me some time to get into the issue, but I believe you are correct: there is an inconsistency between the place where react-admin puts the
meta
value in thecreate
/update
call params, and the place where ra-data-graphql-simple expects it to be.Would you like to open a PR to fix this issue? Thanks.
Thank you for the quick response! Yes, I can open a PR. Probably this week or early next week.
What you were expecting: I'm trying out the new
sparseField
feature of ra-data-graphql-simple added in #9392. However when setting the property:{ meta: { sparseFields: ['id'] } }
it's not taken into account for create/update mutations. The cause seems to be becausebuildCreateUpdateVariables
inbuildVariables
only takesid
anddata
destructured and ignoresmeta
. The unit test for these two query types is written that themeta
property is inside thedata
object, however the types suggest no such difference:UpdateParams
still hasdata: Partial<RecordType>
andmeta?: any
in its type declarations.In short the below code should still use the sparse fields, but it's completely ignoring it:
What happened instead: Sparse fields are not used for create/update calls from
params.meta.sparseFields
, they do seem to work onparams.data.meta.sparseFields
however.Steps to reproduce: It should be easily reproducible/testable by updating the unit tests in
buildVariables.test.ts
for CREATE and UPDATE.meta
property should be on the top level of theparams
variable, not insidedata
.Related code: Unit tests for create/update should use top-level
meta
.Other information:
Environment