You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f9e16f6
Browse filesBrowse the repository at this point in the historyBrowse files
Fix duplicate key crash when a resolver builds an object from context members
ExpressionExtractor credits both context member reads of a nested
construction to the construction node itself, so the same Expression
instance is extracted twice under the one name. Its own comment says that
is expected: "we extract all expression - which may repeat - and we then
replace them by matching the expression object".
ExpressionReplacer's constructor used Dictionary.Add per expression, and
Expression does not override equality, so the second add of that same
instance threw "An item with the same key has already been added". It
fires when the service field is selected below another service field,
where the bulk path is unavailable and ReplaceContext builds an
ExpressionReplacer - nothing is queried, the request fails during
compilation.
Use the indexer instead. The replacer only ever reads this dictionary by
identity, so a repeated entry is redundant rather than lost information,
and fixing it here rather than in the extractor leaves the construction
shapes that extract correctly today untouched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,7 @@
13
13
14
14
## Fixes
15
15
16
+
-#553 - fix `An item with the same key has already been added` when a service field resolver builds an object from multiple context members (e.g. `(ctx, srv) => srv.Get(new Thing { A = ctx.A, B = ctx.B })`) and that field is selected below another service field
16
17
-#498 - fix ExecutableDirectiveLocation naming regression introduced in beta3
schema.UpdateType<Project>(type =>type.ReplaceField("createdBy","Get user that created it").Resolve<UserService>((proj,users)=>users.GetUserById(proj.CreatedBy)));
1392
+
// inner service field - builds one object from 2 context members inside the service call
1393
+
schema.Type<User>().AddField("config","Config for the user").Resolve<ConfigService>((user,srv)=>srv.Get(newProject{Id=user.Id,Name=user.Field2}));
1394
+
1395
+
vargql=newQueryRequest{Query="{ projects { name createdBy { id config { type } } } }"};
0 commit comments