SAHB.GraphQLClient icon indicating copy to clipboard operation
SAHB.GraphQLClient copied to clipboard

How do i pass multiple arguments to the same Query ?

Open sdgarimella opened this issue 4 years ago • 1 comments

This is the graphQL endpoint that i am querying - https://anilist.co/graphiql and here is my query - query A{ Media(id:1, season: SPRING){ id title { romaji english native userPreferred } seasonYear seasonInt season } }

I am trying to query the same using the SAHB GraphQL Client in .Net Fromework. Here is my code that i am using to call that query - GraphQLQueryArgument[] arguments = new GraphQLQueryArgument[] { new GraphQLQueryArgument("id", 1), new GraphQLQueryArgument("season","SPRING"), };

IGraphQLHttpClient client = GraphQLHttpClient.Default(); var filmResponse = await client.Query < MediaQuery > ("https://anilist.co/graphiql", arguments: arguments); Console.WriteLine(filmResponse.Result.Media.seasonYear); Console.ReadKey();

And here are my classes -

class MediaQuery { [GraphQLArguments("id", "ID!", "id")] [GraphQLArguments("season", "String", "season")] public Media Media { get; set; } }

class Media
{
    public string seasonYear { get; set; }
    public string season { get; set; }
}

I am trying to pass both the arguments as attributes. I keep getting the error - "One or more errors occurred." Inner Exception : Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

Am i missing something here ? how can we pass multiple arguments ?

Please help.

Thanks, Surya

sdgarimella avatar Jun 23 '20 20:06 sdgarimella

Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

This suggests https://anilist.co/graphiql is returning a HTML page (the GraphiQL environment). Running a test query shows that your endpoint might actually be https://graphql.anilist.co.

WesToleman avatar Jul 15 '20 07:07 WesToleman