ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.27k stars 748 forks source link

Getting "Specified method is not supported." on executing a querycall #5715

Closed DanteSparda closed 9 months ago

DanteSparda commented 1 year ago

Is there an existing issue for this?

Product

Strawberry Shake

Describe the bug

Hey all, Has anyone seen "Specified method is not supported." error? The request works perfectly in Postman and the browser UI (graphql sandbox). Using StrawberryShake I get the error above and only for this query.

query GetCategories {
  categories {
    data {
      id
      name
    }
  }
}

This query for instance works:

query GetBrands {
  brands {
    data {
      name
    }
  }
}

Fiddler says the result is 200 and it does return the value. image

Inside of the StrawberryShake.OperationResult.Errors>Extensions I can see the value of the response. image

excuse the white flashing :D

Steps to reproduce

  1. Create console application Follow the strawberry setup guide in the site or use this tutorial (https://www.youtube.com/watch?v=6oJlibTwn_4&ab_channel=SingletonSean)

    a. The url I'm using is for a dev env that I shouldn't share on the internet, but I can provide it to a developer that wants to test it 1:1

  2. Paste this code

           var serviceCollection = new ServiceCollection();
    
            serviceCollection
                .AddDemoServicesClient()
                .ConfigureHttpClient(client => client.BaseAddress = new Uri("url I can provide to individuals only"));
    
            IServiceProvider services = serviceCollection.BuildServiceProvider();
    
            var client = services.GetRequiredService<IDemoServicesClient>();
            var categories = await client.GetCategories.ExecuteAsync();
  3. Run it.

The GetCategories is the query from the bug

query GetCategories {
  categories {
    data {
      id
      name
    }
  }
}

Relevant log output

No response

Additional Context?

No response

Version

12.16.0

DanteSparda commented 1 year ago

From what I gathered so far - looks like the __typename wasn't set for the Categories. I don't have access to the GraphQL server, so I'll contact the team and see if setting the typename will resolve this. Will keep this updated

ibramn commented 1 year ago

I have exactly the same issue, how did you resolve this issue ?

glen-84 commented 10 months ago

@DanteSparda Do you have an update? Did setting the __typename resolve the issue?

nollidnosnhoj commented 9 months ago

I recently came across this error while using StrawberryShake. I had to debug the issue and found out that the exception was thrown when the generated StrawberryShake client was trying to deserialize the response into the generated C# type, but failed. It failed because the type from the response did not match the type from the generated C# type. So I had to update my schema.graphql (to match the current graphql schema) and regenerate the C# code, and it works now.

Do not know if this solves the issue, since this exception could be thrown anywhere, but best way to solve this is to use a debugger (whether in Visual Studio or Jetbrains Rider), and run the code locally.

Cheers.

glen-84 commented 9 months ago

Closing, as no response has been received from the author.