public MappingQuery(
     IEfGraphQLService <MappingContext> graphQlService)
 {
     graphQlService.AddSingleField(
         graph: this,
         name: "child",
         resolve: context =>
     {
         return(context.DbContext.Children);
     });
     graphQlService.AddQueryField(
         graph: this,
         name: "children",
         resolve: context =>
     {
         return(context.DbContext.Children);
     });
     graphQlService.AddSingleField(
         graph: this,
         name: "parent",
         resolve: context =>
     {
         return(context.DbContext.Parents);
     });
     graphQlService.AddQueryField(
         graph: this,
         name: "parents",
         resolve: context =>
     {
         return(context.DbContext.Parents);
     });
 }
Beispiel #2
0
 protected FieldType AddSingleField <TGraph, TReturn>(
     Func <ResolveFieldContext <object>, IQueryable <TReturn> > resolve,
     string name = nameof(TReturn))
     where TGraph : ObjectGraphType <TReturn>
     where TReturn : class
 {
     return(efGraphQlService.AddSingleField <TGraph, TReturn>(this, name, resolve));
 }
 protected FieldType AddSingleField <TReturn>(
     Func <ResolveEfFieldContext <TDbContext, object>, IQueryable <TReturn> > resolve,
     Type graphType = null,
     string name    = nameof(TReturn),
     IEnumerable <QueryArgument> arguments = null)
     where TReturn : class
 {
     return(efGraphQlService.AddSingleField(this, name, resolve, graphType, arguments));
 }
 public MultiContextQuery(
     IEfGraphQLService <DbContext1> efGraphQlService1,
     IEfGraphQLService <DbContext2> efGraphQlService2)
 {
     efGraphQlService1.AddSingleField(
         graph: this,
         name: "entity1",
         resolve: context =>
     {
         var userContext = (DbContext1)((Dictionary <string, object>)context.UserContext)["dbContext1"];
         return(userContext.Entities);
     });
     efGraphQlService2.AddSingleField(
         graph: this,
         name: "entity2",
         resolve: context =>
     {
         var userContext = (DbContext2)((Dictionary <string, object>)context.UserContext)["dbContext2"];
         return(userContext.Entities);
     });
 }
 public MultiContextQuery(
     IEfGraphQLService <DbContext1> efGraphQlService1,
     IEfGraphQLService <DbContext2> efGraphQlService2)
 {
     efGraphQlService1.AddSingleField(
         graph: this,
         name: "entity1",
         resolve: context =>
     {
         var userContext = (UserContext)context.UserContext;
         return(userContext.DbContext1.Entities);
     });
     efGraphQlService2.AddSingleField(
         graph: this,
         name: "entity2",
         resolve: context =>
     {
         var userContext = (UserContext)context.UserContext;
         return(userContext.DbContext2.Entities);
     });
 }
    public Query(IEfGraphQLService efGraphQlService) :
        base(efGraphQlService)
    {
        AddQueryField(
            name: "customType",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.CustomTypeEntities);
        });

        AddQueryField(
            name: "skipLevel",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.Level1Entities);
        }, graphType: typeof(SkipLevelGraph));

        AddQueryField(
            name: "manyChildren",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.WithManyChildrenEntities);
        });

        AddQueryField(
            name: "level1Entities",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.Level1Entities);
        }, graphType: typeof(Level1Graph));

        efGraphQlService.AddQueryField(
            this,
            name: "withNullableEntities",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.WithNullableEntities);
        });

        efGraphQlService.AddQueryField(
            this,
            name: "misNamed",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.WithMisNamedQueryParentEntities);
        });

        efGraphQlService.AddQueryField(
            this,
            name: "parentEntities",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.ParentEntities);
        });

        efGraphQlService.AddQueryField(
            this,
            name: "childEntities",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.ChildEntities);
        });

        efGraphQlService.AddQueryConnectionField <ParentGraph, ParentEntity>(
            this,
            name: "parentEntitiesConnection",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.ParentEntities);
        });

        efGraphQlService.AddQueryConnectionField <ChildGraph, ChildEntity>(
            this,
            name: "childEntitiesConnection",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.ChildEntities);
        });

        efGraphQlService.AddQueryField(
            this,
            name: "parentEntitiesFiltered",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.FilterParentEntities);
        });

        efGraphQlService.AddQueryConnectionField <FilterParentGraph, FilterParentEntity>(
            this,
            name: "parentEntitiesConnectionFiltered",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.FilterParentEntities);
        });

        efGraphQlService.AddSingleField(
            this,
            name: "parentEntity",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.ParentEntities);
        });
    }