Skip to content

0.10: GraphQL typing ignores load option #1150

Description

@bmulholland

We have a mutation with an argument that uses GraphQL's loads option, which auto-fetches objects by their ID.

It looks like this: argument :party_ids, [ID], loads: Types::PartyType, as: :parties

The type of the argument coming in to resolve is then T::Array[Party], but the new compiler thinks they're still T::Array[String]

cc @jeffcarbs -- just an FYI, no expectation that you fix this, thanks for the work!

Activity

  1. fazo96 commented on Oct 27, 2023

    @fazo96

    Seems like this is fixed by #1556

  2. xinyifly commented on May 23, 2024

    @xinyifly

    Seems like this is fixed by #1556

    @fazo96 I think current graphql_mutation compiler resolves to something like T::Array[Types::PartyType] instead of T::Array[Party]

  3. fazo96 commented on May 31, 2024

    @fazo96

    That's true @xinyifly I have noticed the same behavior recently

  4. rmosolgo commented on Oct 6, 2026

    @rmosolgo

    I took a look at this but found that it's a tougher problem than I realized. GraphQL-Ruby's loads: ... option expects a GraphQL type class, not an application class. Under the hood, GraphQL-Ruby takes the given ID, loads an object for it (GraphQL-Ruby itself doesn't know what kind of object to expect), then calls the schema's resolve_type hook to make sure that the loaded object does in fact resolve to the configured loads: ... type.

    But def resolve receives the application object, not the GraphQL type. In order for this to work right, we'd need a consistent way to go from a GraphQL type class (eg Types::PartyType) to the Rails class it uses under the hood (eg ::Party). But GraphQL-Ruby itself never actually enforces a one-to-one mapping in this way -- it only requires an object that quacks like a Types::PartyType.

    Because there's no existing basis for this one-to-one mapping, I'm not sure how this could be statically improved. I'm going to keep using one-off sigs 😖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions