Skip to content

Conversation

skanderm
Copy link
Contributor

@skanderm skanderm commented Jul 21, 2025

Types don't seem to get pulled in when using a :struct return type in a calculation with an instance_of constraint. I ran into this as a more complicated circumstance (a calculation -> struct with instance_of constraint (another resource) -> calculation -> union NewType -> array -> struct), but this might be the core of it!

# 1
%{
  errors: [
    %{message: "Field \"structCalc\" must not have a selection since type \"JsonString\" has no subfields.", locations: [%{line: 3, column: 5}]},
    %{message: "Cannot query field \"some\" on type \"JsonString\".", locations: [%{line: 4, column: 7}]}
  ]
}

@zachdaniel
Copy link
Contributor

zachdaniel commented Jul 21, 2025

Thanks for the test! I don't have time to investigate this right now. The issue will likely arise from somewhere in AshGraphql.all_attributes_and_arguments not traversing struct types, would you have a chance to look into it?

@skanderm skanderm force-pushed the add-failing-calc-struct-type-test branch from e8b1854 to 370109b Compare July 21, 2025 02:40
@skanderm
Copy link
Contributor Author

skanderm commented Aug 1, 2025

Just getting back to this. It's looking like there's no logic for traversing the combination of :struct return type and :instance_of constraints (for both single and {:array, :struct}.

The calculation shows up in AshGraphql.all_attributes_and_arguments but there needs to be an extra step to pull SomeStructType.subtype_constraints.

@skanderm skanderm force-pushed the add-failing-calc-struct-type-test branch from 370109b to 7e2a9f5 Compare August 1, 2025 00:09
@skanderm skanderm force-pushed the add-failing-calc-struct-type-test branch from 7e2a9f5 to 892b3ad Compare August 1, 2025 00:10
@skanderm
Copy link
Contributor Author

skanderm commented Aug 1, 2025

I can take a crack at adding the traversal around lib/ash_graphql.ex:747 in nested_attrs/4 unless you'd prefer to do it yourself!

Edit: that might actually not be the right place to change things, but either way happy to try.

@skanderm skanderm marked this pull request as draft August 1, 2025 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants