-
-
Notifications
You must be signed in to change notification settings - Fork 917
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
upgradation of api from 3.1 to 6.0 #3731
Comments
Can you post the exact nuget GraphQL packages and version numbers you were using before and what ones you are trying to use now? |
Ok, makes sense. One question: In your 'before' list I do not see GraphQL.Authorization. Are you adding authorization? If so, I suggest using the authorization library included within GraphQL.Server.All. |
I can help you with the migration. But first, have you read through the migration documents for each version located here: |
yes we have gone through with this upgrade documentation and following it. |
It looks like you’re upgrading from .NET Core 2.2 to .NET Core 7.0 at the same time - is that correct? Or is this a .NET Framework project? |
If you’re still getting the error regarding “IGraphQLTextSerializer not set in DI container” then we should review how it’s wired up in your startup.cs / program.cs files. Can you provide the relevant code? |
Once you have basic “hello world” requests going again then we can fix the date. Probably the date error is due to a field resolver returning a date string for a date graph type instead of returning the date itself. The current version of GraphQL is much more strict about being sure that .NET code returns .NET types, having the scalar convert it to a string when needed. Also on the input side, Newtonsoft by default parses dates, so we need to be sure the date parsing is disabled so the scalar can do this job. So that could be an issue also. |
my main project is in .net core 3.1 and one dependent assembly is in 3.1 also,second one using .net standard 2.0 and we are migrating to 6.0. |
Ok that’s no problem |
The second problem will be due to the GraphQL response not being serialized by the GraphQL serializer implementation. Can you provide the code that the error stops on? |
As for the identity client error, I’m not very familiar with that library, but if you post the code that’s causing the issue I could let you know if I have any ideas. |
your startup looks pretty good. you should be able to remove these lines: services.AddSingleton<IServiceProvider>(s => new FuncServiceProvider(s.GetRequiredService));
services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
//services.AddSingleton<IDocumentWriter, DocumentWriter>();
services.AddSingleton<IGraphQLSerializer, GraphQLSerializer>();
services.AddSingleton<ISchema, DUSSchema>(); and then change this line and add another: //remove:
//options.AddAutoSchema<Query>();
//add:
options.AddSchema<DUSSchema>();
options.AddNewtonsoftJson(); // or options.AddSystemTextJson(); Is |
Can you provide the stack trace for the error you're receiving? Also the definition of the |
I'm also having difficulty finding what |
It is unlikely that will help. |
I'll need this to continue analysis. |
My comment about date parsing is really only applicable when you're using NewtonsoftJson directly, such as through custom middleware or a MVC endpoint. But in your case you are using the ASP.Net Core middleware within GraphQL.NET Server which should have all the default options set up correctly. |
I'd also suggest switching to the SystemTextJson serializer, which is natively async, but it should work identical either way. |
Are there graph types defined for these fields? Or using AutoRegisteringInputObjectGraphType? |
yes we have graphtype defined. |
are they using DateTimeGraphType or DateGraphType ? |
DateTimeGraphType |
Ok then that's your problem. In GraphQL.NET v4 (?) and newer,
It will parse those values and convert them into UTC
See:
You can of course create a custom scalar which will deserialize and serialize New to .NET 6 is the |
Thankyou so much for your response and support,issue has been resolved. |
we are getting error in this now,when we are sending in this casetype '"json" it is throwing error,please guide me. |
Enums are case sensitive now, pursuant to the GraphQL specification. Probably a v4 change. |
all issue has been resolved,thankyou so much for your help and support. |
one issue is pending,once that will resolve i will close this ticket. |
Hi,Do you have any idea how to convert this input parameter enum case sensitive to case insensitive,so it will accept all cases.
|
Add this class: public class CaseInsensitiveEnumGraphType<T> : EnumerationGraphType<T>
where T : Enum
{
/// <inheritdoc/>
public override object? ParseLiteral(GraphQLValue value) => value switch {
GraphQLEnumValue enumValue => Values.FindByName(enumValue.Name.ToString().ToUpperInvariant())?.Value ?? ThrowLiteralConversionError(value),
GraphQLNullValue _ => null,
_ => ThrowLiteralConversionError(value)
};
/// <inheritdoc/>
public override bool CanParseLiteral(GraphQLValue value) => value switch {
GraphQLEnumValue enumValue => Values.FindByName(enumValue.Name.ToString().ToUpperInvariant()) != null,
GraphQLNullValue _ => true,
_ => false
};
/// <inheritdoc/>
public override object? ParseValue(object? value) => value switch {
string s => Values.FindByName(s.ToUpperInvariant())?.Value ?? ThrowValueConversionError(value),
null => null,
_ => ThrowValueConversionError(value)
};
/// <inheritdoc/>
public override bool CanParseValue(object? value) => value switch {
string s => Values.FindByName(s.ToUpperInvariant()) != null,
null => true,
_ => false
};
} Then add this in your startup: // make all enums case insensitive
services.AddTransient(typeof(EnumerationGraphType<>), typeof(CaseInsensitiveEnumGraphType<>)); It should work across your entire codebase with no other code changes, so long as you typically just use |
I have manually define enum graph type and set ResolvedType in my graphs,can you provide any other solution,because i cant change this in my api. |
If you provide a sample of an enumeration graph type I can demonstrate the changes required |
Just change the base type of your enumeration graph types to the one I posted. Should work fine. |
Thankyou so much @Shane32,it is working fine. |
= if you have any solution where it will accept for all date formats,if you help it would be grateful. Thanks |
I would suggest making a custom scalar. You can then customize the date parsing in any way you wish. I would start by duplicating the source code of You will likely need to register the custom scalar with your schema - see this link: Anything that directly references Once complete, your schema will parse date formats based on the code you've written in the custom scalar, and you should have no more trouble. |
Note that this should be pretty easy to do. Let me know if you run into any difficulty. |
Please re-open if you have further issues |
GraphQL.NET doesn't deal with JWTs directly. If you're using GraphQL.NET Server, well it doesn't either except for within the JWT sample application. What code are you using to generate your JWTs? Not that it should do that, but is the lack of decimals a problem? |
Hi,while upgrading the api we are facing issue with DocumentExecutor on below line
await documentexecuter.ExecuteAsync(options).ConfigureAwait(false);
we are getting this values but after upgrading the documentexecutor variable is returning null,
and i am getting some more errors
System.InvalidOperationException: IGraphQLTextSerializer not set in DI container. Add a IGraphQLTextSerializer implementation, for example GraphQL System TextJson.GraphQLSerializer or
GraphQL.NewtonsoftJson.GraphQLSerializer. For more information, see: https://github.com/graphql- dotnet/graphql-dotnet/blob/master/README.md.
at GraphQLDI.GraphQLBuilderBase.<>c.b_0_101ServiceProvider) in //src/GraphQL/DI/GraphQLBuilderBase.cs:line 36 at
Microsoft.Extensions.Dependencylnjection.ServiceLookup.CallSiteRuntimeResolver. VisitDisposeCache(ServiceCallSi te transientCallSite, RuntimeResolverContext context)at Microsoft.Extensions. Dependencyinjection.ServiceLookup.CallSiteVisitor 2 VisitCallSite(ServiceCallSite callSite,TArgument argument)
at Microsoft.Extensions.Dependencyinjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSiteSite. Service ProviderEngineScope scope)
at Microsoft.Extensions.Dependencyinjection.ServiceLookup.DynamicServiceProviderEngine.
<>c_DisplayClass2_0.b_0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType. ServiceProviderEngineScope serviceProviderEngineScope)at
Microsoft.Extensions. DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(ServiceProvider provider. Type service Type)at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T]
(IServiceProvider provider) at GraphQL Server. Transports.AspNetCore.GraphQLHttpMiddleware`1.InvokeAsync(HttpContext context) in PDQS\Graph_QL\src\DUSGraphQLServer Transports.AspNetCore\GraphQLHttpMiddleware.cs:line 77
Argument jobinput' has invalid value. In field 'dateRange': [In field 'startDate: [Expected type 'DateTime', found " 2023-09-27.] In field 'endDate': [Expected type 'DateTime', found "2023-09- 27"]] In field 'scheduleType': [Expected type 'ScheduleType', found Adhoc.] In field 'dataSource: [Expected type DataSourceType', found all.] In field 'outputFormatType': [Expected type 'OutputFormatType", found csv.]"
please help me to resolve those errors.
The text was updated successfully, but these errors were encountered: