I am having a problem similar to this . I have updated my GraphQLHttpClient and now I need to supply an extra parameter, solution give is:
GraphQLHttpClient gql = new GraphQLHttpClient(o => {
o.EndPoint = _config["API:Endpoint"];
o.JsonSerializer = new NewtonsoftJsonSerializer();
});
but this tells me: Error CS1729 'GraphQLHttpClient' does not contain a constructor that takes 1 arguments
I have also tried:
using Newtonsoft.Json
GraphQLHttpClient gql = new GraphQLHttpClient(_options.Url, new Newtonsoft.Json.JsonSerializer());
which gives Error CS1503 Argument 2: cannot convert from 'Newtonsoft.Json.JsonSerializer' to 'GraphQL.Client.Abstractions.Websocket.IGraphQLWebsocketJsonSerializer'
I know very little c# so I'd be grateful for any pointers.
Your first solution correctly tries to use NewtonsoftJsonSerializer
which is an implementation of IGraphQLWebsocketJsonSerializer
to use Newtonsoft.
Your second correctly uses a constructor which takes it, but you have changed it to be Newtonsoft.Json.JsonSerializer
which is not an implementation of IGraphQLWebsocketJsonSerializer
.
What you want is the second one, but with the right type of IGraphQLWebsocketJsonSerializer
:
GraphQLHttpClient gql = new GraphQLHttpClient(_options.Url, new NewtonsoftJsonSerializer());
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.