Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lists in Apollo Federation reference resolvers #7991

Open
luke-pp opened this issue Feb 4, 2025 · 1 comment · May be fixed by #8001
Open

Support lists in Apollo Federation reference resolvers #7991

luke-pp opened this issue Feb 4, 2025 · 1 comment · May be fixed by #8001

Comments

@luke-pp
Copy link

luke-pp commented Feb 4, 2025

Product

Hot Chocolate

Version

14.2.0

Link to minimal reproduction

e96c3b7#diff-9ffdbfd9cc96a0b754318fd0f72577c4f85bbc8721d5ade34204c92a0aa07c25R371

Steps to reproduce

  1. Create a GraphQL type with a reference resolver using HotChocolate.ApolloFederation
  2. Add a field that is a list, and mark it as [External]
  3. Add the list field as an argument to the reference resolver
    Example:
public class ListFieldType
    {
        public ListFieldType(string id, List<double> listField)
        {
            Id = id;
            ListField = listField;
        }
        [Key]
        [External]
        public string Id { get; }
        [External]
        public List<double> ListField { get; }
        public string InternalField { get; set; } = "InternalValue";
        [ReferenceResolver]
        public static ListFieldType GetByExternal(string id, List<double> listField, IResolverContext context)
        {
            return new(id, listField);
        }
    }
  1. Query the reference resolver, passing in a value for the external field

What is expected?

At this point, I expect to see a value passed into the reference resolver's arguments.

What is actually happening?

The value passed into the reference resolver is always null.

Relevant log output

Additional context

I have created a branch that adds this case to the existing tests dealing with External fields. The root cause seems to be that the ArgumentParser class does not currently handle list types - I have also added the beginnings of an implementation in the branch to confirm that adding that missing logic does fix the issue.

While I don't see any explicit confirmation in the Apollo documentation that external list fields are supported, it does seem like something that should work.

I'm happy to create a PR based on the branch linked above if we agree that this functionality is something worth supporting - it'll need a bit of tidying up as there are some edge cases I haven't fully implemented handling for yet, and the way reflection is being used is a bit messy.

@michaelstaib
Copy link
Member

Create a PR and we will see what needs to be done.

@luke-pp luke-pp linked a pull request Feb 6, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants