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 + mutation query field fails #3158

Closed
benmccallum opened this issue Mar 1, 2021 · 3 comments
Closed

Stitching + mutation query field fails #3158

benmccallum opened this issue Mar 1, 2021 · 3 comments
Labels
Area: Stitching Issue is related to schema stitching / federation 🐛 bug Something isn't working 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Milestone

Comments

@benmccallum
Copy link
Collaborator

benmccallum commented Mar 1, 2021

Describe the bug
RelayOptions's AddQueryFieldToMutationPayloads introduced the query field to all mutation payload types, but it doesn't work in stitching. At least I think that's the issue.

To Reproduce
Stitched scenario, in our case we are still doing stitching via .graphql files on the gateway (just in case that matters).

Query like so:

mutation BookingFormSubmitUpdates_Mutation(
  $bookingId: ID!
  $customer: UpdateSupplierSourcedAfterpayBookingCustomerInput!
  $job: UpdateSupplierSourcedAfterpayBookingJobInput!
) {
  updateSupplierSourcedAfterpayBooking(input: {bookingId: $bookingId, customer: $customer, job: $job}) {
    query {
      booking(id: $bookingId) { # <---- comes from a downstream service
        dbId
        id
      }
    }
    errors {
      __typename
      ... on PaymentProcessingHasCommenced {
        message
      }
    }
  }
}

Expected behavior
Mutation executes, query executes, booking is returned.

Actual:

{
  "errors": [
    {
      "message": "Unexpected Execution Error",
      "locations": [
        {
          "line": 6,
          "column": 3
        }
      ],
      "path": [
        "updateSupplierSourcedAfterpayBooking"
      ],
      "extensions": {
        "message": "Value cannot be null. (Parameter 'path')",
        "stackTrace": "   at HotChocolate.Stitching.SelectionPathParser.Parse(String path)\n   at HotChocolate.Stitching.Utilities.FieldDependencyResolver.CollectFieldNames(DelegateDirective directive, IHasName type, ISet`1 dependencies)\n   at HotChocolate.Stitching.Utilities.FieldDependencyResolver.CollectDelegationDependencies(Context context, IHasName type, IOutputField field)\n   at HotChocolate.Stitching.Utilities.FieldDependencyResolver.VisitField(FieldNode node, Context context)\n   at HotChocolate.Language.SyntaxVisitor`2.VisitMany[T](IEnumerable`1 items, TContext context, Action`2 action)\n   at HotChocolate.Stitching.Utilities.FieldDependencyResolver.GetFieldDependencies(DocumentNode document, SelectionSetNode selectionSet, INamedOutputType declaringType)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteSelectionSet(SelectionSetNode node, Context context)\n   at HotChocolate.Language.SyntaxRewriter`1.Rewrite[TParent,TProperty](TParent parent, TProperty property, TContext context, Func`3 visit, Func`2 rewrite)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteFieldSelectionSet(FieldNode node, IOutputField field, Context context)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteField(FieldNode node, Context context)\n   at HotChocolate.Language.SyntaxRewriter`1.RewriteMany[T](IReadOnlyList`1 items, TContext context, Func`3 func)\n   at HotChocolate.Language.SyntaxRewriter`1.Rewrite[TParent,TProperty](TParent parent, TProperty property, TContext context, Func`3 visit, Func`2 rewrite)\n   at HotChocolate.Language.QuerySyntaxRewriter`1.RewriteSelectionSet(SelectionSetNode node, TContext context)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteSelectionSet(SelectionSetNode node, Context context)\n   at HotChocolate.Language.SyntaxRewriter`1.Rewrite[TParent,TProperty](TParent parent, TProperty property, TContext context, Func`3 visit, Func`2 rewrite)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteFieldSelectionSet(FieldNode node, IOutputField field, Context context)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.RewriteField(FieldNode node, Context context)\n   at HotChocolate.Stitching.Delegation.ExtractFieldQuerySyntaxRewriter.ExtractField(NameString sourceSchema, DocumentNode document, OperationDefinitionNode operation, IFieldSelection selection, INamedOutputType declaringType)\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.CreateQuery(IMiddlewareContext context, NameString schemaName, IImmutableStack`1 path, IImmutableStack`1 reversePath)\n   at HotChocolate.Stitching.Delegation.DelegateToRemoteSchemaMiddleware.InvokeAsync(IMiddlewareContext context)\n   at HotChocolate.Utilities.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)\n   at HotChocolate.Execution.Processing.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\n   at HotChocolate.Execution.Processing.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)"
      }
    }
  ]
}

Note: if we expose the booking as a field on the mutation payload ourselves, all is fine. It just seems like stitching + query is a no go and the stack trace clearly says it's something to do with selection set stuff.

Desktop (please complete the following information):

  • OS: Window, Linux
  • HC Version: 11.0.9

Additional context
N/A.

@benmccallum benmccallum added 🌶 hot chocolate 🐛 bug Something isn't working labels Mar 1, 2021
@benmccallum benmccallum added this to the HC-2021-05 milestone Mar 1, 2021
@michaelstaib michaelstaib modified the milestones: HC-2021-06, HC-2021-08 May 28, 2021
@tobias-tengler tobias-tengler added the Area: Stitching Issue is related to schema stitching / federation label Jun 26, 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
@seantleonard
Copy link

Should this still be stale? no PR tracked to address and still mentioned in documentation:

https://chillicream.com/docs/hotchocolate/defining-a-schema/relay

This feature currently doesn't work on a stitching gateway, however this will be addressed in a future release focused on stitching. It's tracked as #3158.

@michaelstaib
Copy link
Member

Yes, we have a new gateway (HotChocolate.Fusion) version coming up with 13.1 so we will not do anything for stitching anymore. The new approach works with this.

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 🐛 bug Something isn't working 🌶️ hot chocolate ⌛ stale Nothing happened with this issue in quite a while
Projects
None yet
Development

No branches or pull requests

4 participants