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

How do i pass multiple arguments to the same Query ? #102

Open
sdgarimella opened this issue Jun 23, 2020 · 1 comment
Open

How do i pass multiple arguments to the same Query ? #102

sdgarimella opened this issue Jun 23, 2020 · 1 comment

Comments

@sdgarimella
Copy link

sdgarimella commented Jun 23, 2020

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

@WesToleman
Copy link

WesToleman commented Jul 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants