Comments (13)
I've tried both query and subscription, with inline both true and false - all four cases are being generated correctly, and accepted by my server.
from sahb.graphqlclient.
When executing the operation you should use the enum in the GraphQLQueryArgument. For example:
var operation = await graphQLSubscriptionClient.ExecuteOperation(new GraphQLQueryArgument("fromSrc", RdSrc.SB));
This should generate the correct query.
from sahb.graphqlclient.
Hmmm, it's making something 'weird'....
What should I put in the argumentType?
[GraphQLArguments("src",
"String", // <- ??
"fromSrc", IsRequired = true)]
from sahb.graphqlclient.
You should put the name of the enumtype in GraphQL. You can find this name using introspection for example using GraphQL Playground or GraphiQL. It could for example be RdSrc.
from sahb.graphqlclient.
Ok (can't believe I hadn't tried that!). Because of the IsRequired, it seems I need "RdSrc!".
I'm still finding it difficult to tie up both ends though. The above sends 0 as the arg value, which my server rejects since it isn't SB or XB. I can get the textual form of the enum, but that is then a string and so (obviously) gets quoted by GraphQLQueryArgument....
Although the [Apollo] server docs suggest the enums can have alternative values, I've not got it to accept 0 or "XB" - and in any case that would kinda ignore the use of nicely typed enums?
from sahb.graphqlclient.
This may or may not be a similar thing, but I'm also having trouble doing an introspection ValidateGraphQLType on a query which also takes this enum as an argument:
"Argument at QryRdByEmitter has a invalid type. Expected is , actual is RdSrc!."
from sahb.graphqlclient.
Hello,
You can use EnumMember (Newtonsoft.Json).
public enum RdSrc
{
[EnumMember(Value = "SB")]
SB,
[EnumMember(Value = "XB")]
XB
}
Would you create a issue on the other issue with the introspection? This is clearly a bug
from sahb.graphqlclient.
Still trying to work through that suggestion, but isn't it going to still have the problem of giving something of type string, and end up quoted? i.e.
subscription subRd{subRd(src:"SB"){src record}}
whereas an enum param needs to be
subscription subRd{subRd(src:SB){src record}}
I suspect some additional classes/types would be needed to support this?
from sahb.graphqlclient.
I have found out the problem is the default way Newtonsoft.Json serializes enums. I have created some testcode which shows how it's possible to override the default behaviour.
from sahb.graphqlclient.
I'm not surprised that its an awkward case - in any programming language an enum is just used as-is, as in GraphQL. But through any intermediate serializing like JSON/XML/etc, they tend to quote the 'values'
from sahb.graphqlclient.
You are completely correct. According to the spec it should be "values are represented as unquoted names".
This should therefore be handled in this library possible by providing a default custom JsonConverter.
from sahb.graphqlclient.
I have found the problem in GraphQLQueryGeneratorFromFields
. Currently it uses JsonConvert to serilize the value at line 246. This should be handled in a better way.
from sahb.graphqlclient.
It should now be fixed for all inlined arguments. I'm not sure if it should also be updated for variables would you check if your server has the same problem for not inlined arguments?
[GraphQLArguments("src", "RdSrc!", "fromSrc", inlineArgument: false, isRequired: true)]
from sahb.graphqlclient.
Related Issues (20)
- Introspection validation fails with enum in query HOT 2
- Support reconnecting GraphQLSubscriptionClient
- Implement IAsyncEnumerable on IGraphQLSubscriptionOperation
- Support Httpclientfactory in GraphQL Client Builder for usage with ASP.net Core
- Accessing the log messages HOT 1
- Add CancellationToken support HOT 2
- Custom scalars HOT 1
- Schema validation fails when fields are nullable HOT 7
- Subscription [GraphQL] errors not being caught HOT 9
- Creating GraphQL model using introspection
- I'm trying to subscribe to this API, but I don't receive any response. These are my classes and this is the subscription HOT 6
- Mutate Guidance HOT 2
- How do I transform the names of parameters for a class that is used as a query argument? HOT 3
- How do I add arguments to a model nested in the query? HOT 1
- .NET Standard versions HOT 1
- How do i pass multiple arguments to the same Query ? HOT 1
- Null dereference bug during deserialization
- GraphQLArgumentAttribute doens't exist? HOT 2
- Support for OperationName
- Not Auth header, just a token
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sahb.graphqlclient.