graphql-dotnet / graphql-dotnet/graphql-client

Subscription: Cannot execute request if no query is specified

Open
#353 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

I have used the sample code as described here
https://github.com/graphql-dotnet/graphql-client

My code is:
```
public static async void MRTestSub()
{
var graphQLClient = new GraphQLHttpClient(serviceURL, new NewtonsoftJsonSerializer());

var usdbActionAddedRequest = new GraphQLRequest
{
Query = @"
subscription {
dbActionAdded{
name
id
}
}"
};

try
{

IObservable> subscriptionStream
= graphQLClient.CreateSubscriptionStream(usdbActionAddedRequest);

var subscription = subscriptionStream.Subscribe(response =>
{
Console.WriteLine($"DbAction '{response.Data.DbActionAdded.Name}' added");
});

Console.WriteLine("=Sub===============");
}
catch (Exception x)
{
Console.WriteLine("*** Exception: "+x.Message);
}
return;
}

```
but when the client tries to subscribe my asp.net core server gives an exception

> info: Microsoft.Hosting.Lifetime[0]
> Now listening on: https://localhost:6061
> info: Microsoft.Hosting.Lifetime[0]
> Now listening on: http://localhost:6060
> info: Microsoft.Hosting.Lifetime[0]
> Application started. Press Ctrl+C to shut down.
> info: Microsoft.Hosting.Lifetime[0]
> Hosting environment: Development
> info: Microsoft.Hosting.Lifetime[0]
> Content root path: D:\GraphQL2\Movie_reviews-1\movie-reviews-main-1
> fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
> An unhandled exception has occurred while executing the request.
> System.InvalidOperationException: Cannot execute request if no query is specified
> at GraphQL.DocumentExecuter.ExecuteAsync(ExecutionOptions options) in /_/src/GraphQL/Execution/DocumentExecuter.cs:line 56
> at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.ExecuteAsync(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken) in /_/src/Core/Internal/DefaultGraphQLExecuter.cs:line 54
> at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in /_/src/Transports.AspNetCore/GraphQLHttpMiddleware.cs:line 144
> at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
> fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
> An unhandled exception has occurred while executing the request.
> System.InvalidOperationException: Cannot execute request if no query is specified
> at GraphQL.DocumentExecuter.ExecuteAsync(ExecutionOptions options) in /_/src/GraphQL/Execution/DocumentExecuter.cs:line 56
> at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.ExecuteAsync(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken) in /_/src/Core/Internal/DefaultGraphQLExecuter.cs:line 54
> at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in /_/src/Transports.AspNetCore/GraphQLHttpMiddleware.cs:line 144
> at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
> fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
> An unhandled exception has occurred while executing the request.
> System.InvalidOperationException: Cannot execute request if no query is specified
> at GraphQL.DocumentExecuter.ExecuteAsync(ExecutionOptions options) in /_/src/GraphQL/Execution/DocumentExecuter.cs:line 56
> at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.ExecuteAsync(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken) in /_/src/Core/Internal/DefaultGraphQLExecuter.cs:line 54
> at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in /_/src/Transports.AspNetCore/GraphQLHttpMiddleware.cs:line 144
> at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
> fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
> An unhandled exception has occurred while executing the request.
> System.InvalidOperationException: Cannot execute request if no query is specified
> at GraphQL.DocumentExecuter.ExecuteAsync(ExecutionOptions options) in /_/src/GraphQL/Execution/DocumentExecuter.cs:line 56
> at GraphQL.Server.Internal.DefaultGraphQLExecuter`1.ExecuteAsync(String operationName, String query, Inputs variables, IDictionary`2 context, IServiceProvider requestServices, CancellationToken cancellationToken) in /_/src/Core/Internal/DefaultGraphQLExecuter.cs:line 54
> at GraphQL.Server.Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in /_/src/Transports.AspNetCore/GraphQLHttpMiddleware.cs:line 144
> at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
>
>

What is wrong? How to fix it?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.