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

Stitching: "01 is not a valid GraphQL type name" when passing json as input to mutation #3859

Closed
gao-artur opened this issue Jun 23, 2021 · 9 comments
Assignees
Labels
Area: Stitching Issue is related to schema stitching / federation 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Milestone

Comments

@gao-artur
Copy link

gao-artur commented Jun 23, 2021

Hey,
The following issue reproduced only on stitching service, everything works correctly on regular service.

The schema:

schema {
  query: Query
  mutation: Mutation
}

type Mutation {
  do(input: MyInput): MyOutput
}

type MyOutput {
  params: PropertiesDictionary
}

type Query {
  hot: String
}

input MyInput {
  params: PropertiesDictionary
}

scalar PropertiesDictionary

PropertiesDictionary taken from here

Request:

mutation doWork($input: MyInput){
  do(input: $input){
    params
  }
}

Variables:

{
  "input":{
    "params": {
      "01": "zzz"
    }
  }
}

Response:

{
  "errors": [
    {
      "message": "Unexpected Execution Error",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "do"
      ],
      "extensions": {
        "message": "`01` is not a valid GraphQL type name. (Parameter 'value')",
        "stackTrace": "   at HotChocolate.NameString..ctor(String value)\r\n   at HotChocolate.NameString.ConvertFromString(String s)\r\n   at HotChocolate.NameString.op_Implicit(String s)\r\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteObjectField(ObjectFieldNode node, Context context)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteMany[T](IReadOnlyList`1 items, TContext context, Func`3 func)\r\n   at HotChocolate.Language.SyntaxRewriter`1.<>c__DisplayClass20_0`2.<RewriteMany>b__0(IReadOnlyList`1 p, TContext c)\r\n   at HotChocolate.Language.SyntaxRewriter`1.Rewrite[TParent,TProperty](TParent parent, TProperty property, TContext context, Func`3 visit, Func`2 rewrite)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteMany[TParent,TProperty](TParent parent, IReadOnlyList`1 property, TContext context, Func`3 visit, Func`2 rewrite)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteObjectValue(ObjectValueNode node, TContext context)\r\n   at HotChocolate.Language.QuerySyntaxRewriter`1.Rewrite(ISyntaxNode node, TContext context)\r\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteObjectField(ObjectFieldNode node, Context context)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteMany[T](IReadOnlyList`1 items, TContext context, Func`3 func)\r\n   at HotChocolate.Language.SyntaxRewriter`1.<>c__DisplayClass20_0`2.<RewriteMany>b__0(IReadOnlyList`1 p, TContext c)\r\n   at HotChocolate.Language.SyntaxRewriter`1.Rewrite[TParent,TProperty](TParent parent, TProperty property, TContext context, Func`3 visit, Func`2 rewrite)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteMany[TParent,TProperty](TParent parent, IReadOnlyList`1 property, TContext context, Func`3 visit, Func`2 rewrite)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteObjectValue(ObjectValueNode node, TContext context)\r\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteValue(IValueNode node, TContext context)\r\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteValueNode(NameString sourceSchema, IInputType inputType, IValueNode value)\r\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.ResolveUsedRequestVariables(ISchema schema, NameString schemaName, ExtractedField extractedField, IVariableValueCollection requestVariables, ExtractFieldQuerySyntaxRewriter rewriter)+MoveNext()\r\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.CreateVariableValues(IMiddlewareContext context, NameString schemaName, IEnumerable`1 scopedVariables, ExtractedField extractedField, ExtractFieldQuerySyntaxRewriter rewriter)\r\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.CreateQuery(IMiddlewareContext context, NameString schemaName, IImmutableStack`1 path, IImmutableStack`1 reversePath)\r\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.InvokeAsync(IMiddlewareContext context)\r\n   at HotChocolate.Utilities.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)\r\n   at HotChocolate.Execution.Processing.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\r\n   at HotChocolate.Execution.Processing.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)"
      }
    }
  ],
  "data": {
    "do": null
  }
}
@gao-artur
Copy link
Author

Interestingly that if changing the variables slightly the error disappears. This one works correctly:
Query:

mutation doWork($params: PropertiesDictionary){
  do(input: {params:$params}){
    params
  }
}

Variables:

{
  "params":{
    "01": "zzz"
    }
}

@gao-artur
Copy link
Author

@michaelstaib michaelstaib added ❓ question This issue is a question about feature of Hot Chocolate. and removed 🐛 bug labels Jun 24, 2021
@michaelstaib
Copy link
Member

The issue is that objects are serialized to object value nodes that follow https://spec.graphql.org/June2018/#Name for keys. This is by design for the current stitching engine. The new version which is slated for end of august will work differently and amend this design flaw. I am closing this issue since we are already working on it.

@gao-artur
Copy link
Author

@michaelstaib can you propose some workaround? This is a blocking issue for us for replacing graphql-dotnet with HC. Unfortunately we can't use the workaround from my second comment because Apollo that sits in front of HC gateway will normalize variables to the first form.

@michaelstaib
Copy link
Member

I do not have a workaround for this. The release of the stitching release is at the end of August so it is not that far off. The issue here is the nature of the scalar. The August release focuses solely on stitching and will fix such errors.

We however would accept a PR for a patch release of 11.3.x. So, if you can debug it and find the exact cause we can get it in a release for you.

The core team is really busy at the moment working on the new stitching gateway release which fixed such issues thus we really have no capacity for a quick fix.

All people of the core team do this in their free time and are not paid for this work. I get that this might block you but a solution will be in the August release.

@gao-artur
Copy link
Author

@michaelstaib challenge accepted 😀
The bug is in this line

Rewrite(node.Value, context);

I'm wondering what will be the correct fix: changing context --> cloned or removing this line completely?
Rewrite's return value is ignored here and it doesn't seems to have side effects on its arguments (am I missing something?).
This line was added by PR #1746

@michaelstaib
Copy link
Member

@PascalSenn can you have a look since you added this?

@michaelstaib michaelstaib added the Area: Stitching Issue is related to schema stitching / federation label Jun 27, 2021
@PascalSenn PascalSenn self-assigned this Jun 29, 2021
@PascalSenn PascalSenn reopened this Jun 29, 2021
@PascalSenn PascalSenn added this to the HC-2021-06 milestone Jun 29, 2021
@michaelstaib michaelstaib modified the milestones: HC-2021-08, HC-2021-09 Jul 27, 2021
@stale
Copy link

stale bot commented May 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the ⌛ stale Nothing happened with this issue in quite a while label May 4, 2022
@stale stale bot closed this as completed May 11, 2022
@gao-artur
Copy link
Author

Please reopen, there is unfinished PR to fix the issue.

@michaelstaib michaelstaib removed the ❓ question This issue is a question about feature of Hot Chocolate. label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Stitching Issue is related to schema stitching / federation 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants