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);
     });
 }
Esempio n. 2
0
 protected FieldType AddQueryField <TGraph, TReturn>(
     string name,
     Func <ResolveFieldContext <TSource>, IQueryable <TReturn> > resolve,
     IEnumerable <QueryArgument> arguments = null)
     where TGraph : ObjectGraphType <TReturn>
     where TReturn : class
 {
     return(efGraphQlService.AddQueryField <TSource, TGraph, TReturn>(this, name, resolve, arguments));
 }
Esempio n. 3
0
 protected FieldType AddQueryField <TReturn>(
     string name,
     Func <ResolveEfFieldContext <TDbContext, object>, IQueryable <TReturn> > resolve,
     Type?graphType = null,
     IEnumerable <QueryArgument>?arguments = null)
     where TReturn : class
 {
     return(efGraphQlService.AddQueryField(this, name, resolve, graphType, arguments));
 }
Esempio n. 4
0
    public Query(IEfGraphQLService efGraphQlService) : base(efGraphQlService)
    {
        AddQueryField <SkipLevelGraph, Level1Entity>(
            name: "skipLevel",
            resolve: context =>
        {
            var dataContext = (MyDataContext)context.UserContext;
            return(dataContext.Level1Entities);
        });

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

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

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

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

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

        efGraphQlService.AddQueryField <ChildGraph, ChildEntity>(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 <FilterParentGraph, FilterParentEntity>(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);
        });
    }