Пример #1
0
        protected override void Configure(IObjectTypeDescriptor <Mutation> descriptor)
        {
            base.Configure(descriptor);

            descriptor.Include <ProjectMutations>();
            descriptor.Field("cars").Resolver(x => x.Resolver <CarsMutations>());
        }
Пример #2
0
        protected override void Configure(IObjectTypeDescriptor <Book> descriptor)
        {
            descriptor.Field(t => t.Id)
            .Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >()
            .Description("The name of the book");
            descriptor.Field(t => t.ImageUrl)
            .Type <StringType>();
            descriptor.Field(t => t.Description)
            .Type <StringType>();

            descriptor.Ignore(t => t.AuthorId);

            descriptor.Field(t => t.Reviews)
            .Type <NonNullType <ListType <BookReviewType> > >()
            .Argument("skip", arg => arg.Type <IntType>())
            .Argument("first", arg => arg.Type <IntType>())
            .Resolver(ctx =>
            {
                var repository = ctx.Service <IBookReviewRepository>();
                var book       = ctx.Parent <Book>();
                var skip       = ctx.Argument <int?>("skip") ?? 0;
                var first      = ctx.Argument <int?>("first") ?? 100;

                return(repository.FindAll()
                       .Where(x => x.BookId == book.Id)
                       .OrderByDescending(x => x.CreatedAt)
                       .Skip(skip)
                       .Take(first));
            });

            descriptor.Include <BookResolvers>();
        }
Пример #3
0
 protected override void Configure(IObjectTypeDescriptor <Product> descriptor)
 {
     descriptor.Name("Product");
     descriptor.Description("A product for a webshop");
     descriptor.BindFields(BindingBehavior.Explicit);
     descriptor.Include <Resolvers.ProductResolver>();
 }
Пример #4
0
        protected override void Configure(IObjectTypeDescriptor <Catalog> descriptor)
        {
            descriptor.Name("Catalog");
            descriptor.Description("A named collection of products");

            descriptor.BindFields(BindingBehavior.Explicit);
            descriptor.Include <API.Resolvers.CatalogResolver>();
        }
Пример #5
0
        protected override void Configure(IObjectTypeDescriptor <Query> descriptor)
        {
            descriptor.Name("Query");
            descriptor.Description("Provides access to queries");

            descriptor.BindFields(BindingBehavior.Explicit);
            descriptor.Include <Resolvers.QueryResolver>();
        }
Пример #6
0
        protected override void Configure(IObjectTypeDescriptor <Author> descriptor)
        {
            descriptor.Field(t => t.Id)
            .Type <NonNullType <IdType> >();
            descriptor.Field(t => t.Name)
            .Type <NonNullType <StringType> >()
            .Description("The name of the author");
            descriptor.Field(t => t.ImageUrl)
            .Type <StringType>();

            descriptor.Field("bookCount")
            .Type <IntType>()
            .Resolver(ctx =>
            {
                var repository = ctx.Service <IBookRepository>();
                var author     = ctx.Parent <Author>();

                return(repository.FindAll().Count(x => x.AuthorId == author.Id));
            });

            descriptor.Include <AuthorResolvers>();
        }
Пример #7
0
 protected override void Configure(IObjectTypeDescriptor <Mutation> descriptor)
 {
     descriptor.Name("Mutation");
     descriptor.BindFields(BindingBehavior.Explicit);
     descriptor.Include <MutationResolver>();
 }
Пример #8
0
 protected override void Configure(IObjectTypeDescriptor <Mutation> descriptor)
 {
     descriptor.Include <PostResolver>();
 }
Пример #9
0
 protected override void Configure(IObjectTypeDescriptor <Enrollment> descriptor)
 {
     descriptor.Include <EnrollmentResolvers>();
 }