contrib icon indicating copy to clipboard operation
contrib copied to clipboard

test: add a test to capture failed gql array coercion for nested pagination orderBy

Open matt-silo opened this issue 7 months ago • 0 comments

I believe that the nested pagination is not respecting the GraphQL list input coercion. I've added a test to demonstrate this. Note that the test passes if you change the nested input to children(orderBy: [{direction: DESC, field: PRIORITY_ORDER}]) (ie pass the same argument as a single-element list to orderBy).

I believe this bug was introduced in https://github.com/ent/contrib/pull/495 specifically in the method fieldArgs in entgql/template/collection.tmpl. From my debugging, it appears that graphql.FieldContext.Args contains a slice (ie already coerced), but graphql.CollectedField.ArgumentMap() contains the un-coerced input as a map.

I would be happy to write a fix but I don't fully understand the implications of the pull request I referenced above, and I'm not sure why getting the args from the child field context was broken before. If getting the coerced args from the field context is not possible, my other suggestion is to add cases for non-slice types in the multiOrder branch here: https://github.com/ent/contrib/blob/5ae020b12cec83617e4cd09fffc0c8593d3de405/entgql/template/collection.tmpl#L213 I'm happy to add this if you think it makes sense and would accept such a change.

matt-silo avatar Jul 16 '24 21:07 matt-silo