charlesdevandiere / graphql-query-builder-dotnet Goto Github PK
View Code? Open in Web Editor NEWA .NET GraphQL query builder
Home Page: https://charlesdevandiere.github.io/graphql-query-builder-dotnet/
License: MIT License
A .NET GraphQL query builder
Home Page: https://charlesdevandiere.github.io/graphql-query-builder-dotnet/
License: MIT License
I need to filter a query based on nullable field. Currently I cannot use the query builder to say : { neq: null } because this triggers compiler error CS0828. In order to use the null filtration properly, I've to explicitly replace all occurrences of "null" with null. It would be nice if the builder does this task for me.
Hi guys,
We are happily using GraphQL.Query.Builder to build our queries.
There one minor problem though: the latest release depends on Newtonsoft.Json 11.0.1.
It would be good to upgrade its dependencies to a more recent release, like 12.0.3.
This would save some hassle with bindingRedirect's in exe.config files, as most of the GraphQL.Server 3.x dependencies are now using Newtonsoft.Json 12.0.3.
Kind regards,
Reureu
Hi there,
Does GraphQL.Query.Builder support unions?
https://graphql.org/learn/schema/#union-types
If not, have you got any plan to support unions in a not too distant future?
Regards,
Reureu
I'm trying to create a mutation query that contains an KeyValue property with possible Null value, following we have an example:
Dice.SoldAt is a Nullable<DateTime> that is null at when it is created on api. new Dictionary<string, DateTime?> { {"dice_id", Dice.Id}, {"sold_at", Dice.SoldAt} ... };
And when I try to build my query, I got an null exception.
This is the exception message.
Unsupported Query Parameter, Type Found : System.Collections.Generic.KeyValuePair
2[System.String,System.Nullable
1[System.DateTime]]
How to create a query which accepts nullable values?
var query = new Query<Company>("companies", new()
{
Formatter = CamelCasePropertyNameFormatter.Format
})
.AddField(p => p.Name)
.AddField(p => p.Sites, sites =>
sites.AddField(p => p.Name))
.AddArgument("where", """{name: { contains: "Hallo" }}""")
.AddArgument("order", """{name: DESC }""")
.Build();
generated output:
companies(where: "{name: { contains: \"Hallo\" }}", order: "{name: DESC }"){ name sites{ name} }
expected output:
{ companies(where: {name: { contains: "Hallo" }}, order: { name: DESC }) {name, sites {name} } }
just tried out our library but im having trouble generating correct queries with where and order
For a project that I'm working on, at runtime, I'm generating GraphQL queries that are displayed to the user. Therefore, I wanted the output of your library to contain appropriate line breaks and indentations. I've accomplished this on my own fork, but wondered if there is any interest in me providing a PR here to add this optional formatting to the output. Thanks.
By removing the where TSource : class restrictions you will allow to work with records instead of classes.https://github.com/charlesdevandiere/graphql-query-builder-dotnet/pull/13#issue-545115773
Is this dead? It looks like you need an instance of IGraphQLWebsocketJsonSerializer
to instantiate GraphQLHttpClient
but the references lead nowhere.
Have interface :
interface IFoo
{
string Value {get;set;}
}
Have class
class Foo : IFoo
{
}
Extension code:
public static IQuery<T> WithValue<T>(this IQuery<T> query)
where T : class, IFoo
{
return query.AddField(x => x.Value);
}
Call :
IQuery<Foo> fields = new Query<Foo>().WithValue()
Expected : value property should be added to query
Observed: ArgumentException fired from QueryOf{T}.cs
Reason: Foo implements the IFoo and not delivered from it. So call to type.IsSubclassOf at line 229 of QueryOf{T} is not valid
Solution: replace call to IsSubclassOf by IsAssignableFrom to allow interface as base type
This PR should fix it: 97eb062
@charlesdevandiere , Could you take a look please?
Would love to see this drop the Newtonsoft dependency.
Hi. I'm trying to put and object as param but is throwing an exception when I execute query.Builder().
My object is :
class Filter {
int parent;
int amount;
List<Clauses> clauses;
}
I am trying to create Arguments, but isn't working.
What I've tried:
//creating arguments
var arguments = new Dictionary<string, object>();
arguments.Add("filters", new filters { parent = 1, amount = 15 });
var query = new Query<MyType>("MyTypes")
.AddArguments(arguments)[...]
query.Build();
Throws InvalidDataException: Unsupported Query Parameter
I've tried this too, but without any success.
var query = new Query<MyType>("MyTypes")
.AddArguments(new {filters, arguments)[...]
query.Build();
The same error. How could I create a request using Filter object?
I really like this tool, but can't figure out how to add argument "sortKey:TITLE" to use with Shopify's GraphQL. Anybody?
Hi, @charlesdevandiere
First of all, thank you so much, I guess a lot of programming lives were saved thanks to your efforts : )
But I have found a tiny issue with the Argument list building.
The Formatter from Query is not passed to the QueryStringBuilder, so in case if there is an object in the Query Arguments, the Formatter is not applied to the object.
Can I make a pull request to fix that?
Hi,
i have the following method:
public string GetQuery(params Expression<Func<MyClass, object>>[] properties){}
so i able to use it this way:
GetQuery(x => x.FirstName, x => x.NestedProp.NestedValue);
how can i map the properties array to a valid IQuery?
tried the following:
foreach (var property in properties)
{
if (property.Body is MemberExpression)
{
// this works for MemberExpressions only
query.AddField(property);
}
else
{
// here i have to handle nested expressions "x.NestedProp.NestedValue"
// i'm not sure how to map the UnaryExpression to the query
}
}
can someone please give me a hint?
thanks in advanced
Or do you plan to extend this library with mutations?
Hello! Is there a way to use query variables in the builder?
Thanks for this project.
I've been looking for such builder for a while.
I've write a GraphQL query builder and the syntax is similar to yours.
I will follow your project with attention.
Hi! Thanks a lot for this Library! It's a life saver.
However, I'm trying to use the Query with GraphQL.Client.
From the look of it, it seems that the problem is that the variables for the query are passed separated (as parameters) and the parameter definition on the query is just a $token
that gets replaced with the variables
on the requets to the server.
Do you think its a good idea to implement the builder in a way that it can generate 3 values?:
I could start working on something like this, but im not sure if you might have a way to use the queries on GraophQL.Client without this change.
Cheers!
Please add support for long at:
QueryStringBuilder:FormatQueryParam
Hi charles,
how can send object parameter in C# like entity:{test:"",test1:""}.
Thanks
Dharuman N
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.