Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

New Version 0.32. Query Model 'ModelConventionConnection' is already registered #64

Open
rheid opened this issue Jan 24, 2021 · 4 comments

Comments

@rheid
Copy link
Contributor

rheid commented Jan 24, 2021

Hi David Lee, thank you very much for the update to the GraphQL version of .NET. I have started to switch to this version and have found a few problems. I am using two Querys variables with optional values. These are now throwing an exception in the new version.

        queryBuilderFactory.Create<Event>(coreQuery, "GetEvent")
        .WithPaging()
        .WithParameterBuilder()
        .WithProperty(x => x.Audiences, true)
        .WithProperty(x => x.Language, true)
        .WithProperty(x => x.Navigation, true)
        .WithProperty(x => x.MainTopics, true)
        .WithProperty(x => x.Name, true)
        .WithProperty(x => x.DateStart, true)
        .WithProperty(x => x.Place,true)
        .WithProperty(x => x.Abstract, true)
        .WithProperty(x => x.Description,true)

        .BeginQuery<Event>()

        .BuildQueryResult(ctx =>
        {
            var query = ctx.GetQueryResults<Event>();
            ctx.SetResults(query.OrderByDescending(q => q.CreatedOn).ToList());
        })
        .BuildQuery()
        .BuildWithListResult();


        queryBuilderFactory.Create<Page>(coreQuery, "GetPage")
            .WithPaging()
            .WithParameterBuilder()
            .WithProperty(x => x.Audiences, true)
            .WithProperty(x => x.Language, true)
            .WithProperty(x => x.Navigation, true)
            .WithProperty(x => x.MainTopics, true)
            .WithProperty(x => x.Name, true)
            .WithProperty(x => x.CreatedOn, true)
            .BeginQuery<Page>()

            .BuildQueryResult(ctx =>
            {
                var query = ctx.GetQueryResults<Page>();
                ctx.SetResults(query.OrderByDescending(q => q.CreatedOn).ToList());
            })
            .BuildQuery()
            .BuildWithListResult();

2021-01-24T17:08:49.819Z] Executed 'graphql' (Failed, Id=02497ed2-43ed-44cb-86f5-949e83684772, Duration=17089ms)
[2021-01-24T17:08:49.821Z] System.Private.CoreLib: Exception while executing function: graphql. GraphQL: Unable to register GraphType 'GraphQL.Types.Relay.ConnectionType2[[Eklee.Azure.Functions.GraphQl.ModelConventionType1[[genesis.com.api.Models.Page, genesis.com.api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Eklee.Azure.Functions.GraphQl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[GraphQL.Types.Relay.EdgeType1[[Eklee.Azure.Functions.GraphQl.ModelConventionType1[[genesis.com.api.Models.Page, genesis.com.api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Eklee.Azure.Functions.GraphQl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], GraphQL, Version=3.3.1.0, Culture=neutral, PublicKeyToken=null]]' with the name 'ModelConventionConnection';
the name 'ModelConventionConnection' is already registered to 'GraphQL.Types.Relay.ConnectionType2[[Eklee.Azure.Functions.GraphQl.ModelConventionType1[[genesis.com.api.Models.Event, genesis.com.api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Eklee.Azure.Functions.GraphQl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[GraphQL.Types.Relay.EdgeType1[[Eklee.Azure.Functions.GraphQl.ModelConventionType1[[genesis.com.api.Models.Event, genesis.com.api, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Eklee.Azure.Functions.GraphQl, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], GraphQL, Version=3.3.1.0, Culture=neutral, PublicKeyToken=null]]'.

@seekdavidlee
Copy link
Owner

Hi @rheid - This is a known issue with GraphQL.NET library where I have reported it in graphql-dotnet/relay#72. In the meantime, the workaround is to create a separate endpoint to host your paging implementation.

See documentation: https://github.com/seekdavidlee/Eklee-Azure-Functions-GraphQl/blob/master/Documentation/Queries.md#paging-implementation

@rheid
Copy link
Contributor Author

rheid commented Jan 24, 2021

@seekdavidlee Thank you for your super quick reply. I am quite sure that I have understood this correctly or that I can implement it. Do you have an example? Should these endpoints be implemented again under a different name for the paging?

public static class GraphQLFunction { [ExecutionContextDependencyInjection(typeof(FunctionModule))] [FunctionName("graphql")] public static async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log, ExecutionContext executionContext) { return await executionContext.ProcessGraphQlRequest(req); } }

A small code example would help.

@seekdavidlee
Copy link
Owner

Yes @rheid - You can refer to the example project where in my same project Eklee.Azure.Functions.GraphQl.Example, I have multiple endpoints. You would create a new Azure Function, new AutoFac Module, new Mutation, new Query specifically for each paging Model you are exposing. Via dependency injection, they are seen as different instances, and so the error from GraphQL.NET wouldn't surface.

image

@rheid
Copy link
Contributor Author

rheid commented Jan 24, 2021

@seekdavidlee I'll have a look at that tomorrow. thank you very much.

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

No branches or pull requests

2 participants