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

Aliased field in mutation input type does not get set when argument is a list #1882

Closed
chrisg2 opened this issue Sep 28, 2020 · 5 comments · Fixed by #1893
Closed

Aliased field in mutation input type does not get set when argument is a list #1882

chrisg2 opened this issue Sep 28, 2020 · 5 comments · Fixed by #1893
Assignees
Labels
bug Something isn't working
Milestone

Comments

@chrisg2
Copy link

chrisg2 commented Sep 28, 2020

Description

Field values do not get set from an mutation's input argument when the field has an alias and the input argument is a list of input objects.

This appears to be in a similar vein to bugs #850 and #1358, but this behavior remains despite both those bugs being fixed. As far as I have observed, field aliases work if the mutation argument is a single value (not a list) - I have only observed this problem affecting arguments that are a list.

Steps to reproduce

See unit test at PR #1881.

Configure a field with an alias in MyEntityInputType:

public class MyEntityInputType : InputObjectGraphType<MyEntity>
{
	public MyEntityInputType() { Field("fieldAlias", x => x.BField); }
}

public class MyEntity
{
	public int BField { get; set; }
}

Configure a mutation like:

Field<BooleanGraphType>()
	.Name("mutateMyEntity")
	.Argument<ListGraphType<MyEntityInputType>>("multipleEntities")
	.Resolve(context => {
		var es = context.GetArgument<List<MyEntity>>("multipleEntities");
		es[0].BField.ShouldBe(4);
		return true;
	});

Execute a mutation query like the following:

mutation {
	mutateMyEntity( multipleEntities: [{ fieldAlias: 4 }] )
}

Expected result

The es[0].BField.ShouldBe(4) assertion succeeds.

Actual result

The BField value that comes through is 0 and the ...ShouldBe(4) assertion fails.

Environment

graphql-dotnet version 3.0.0

@Shane32
Copy link
Member

Shane32 commented Sep 28, 2020

@chrisg2 Thanks for the test; it demonstrates the bug very well.

@sungam3r Do you want to look at this or should I?

@sungam3r
Copy link
Member

I will.

@sungam3r
Copy link
Member

Done

@chrisg2
Copy link
Author

chrisg2 commented Oct 23, 2020

Thanks for fixing!

@sungam3r
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants