Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

GraphQL Conventions Library for .NET

License

NotificationsYou must be signed in to change notification settings

embracesbs/conventions

 
 

Repository files navigation

Introduction

GraphQL .NET has been around for a while. This library is a complementary layer on top that allows you to automatically wrap your .NET classes into GraphQL schema definitions using existing property getters and methods as field resolvers.

In short, this project builds on top of the following components:

Installation

Download and install the package fromNuGet:

PS>Install-Package GraphQL.Conventions

The following targets are available:

  • .NET Framework 4.5
  • .NET Platform Standard 1.5

Getting Started

Implement your query type:

[ImplementViewer(OperationType.Query)]publicclassQuery{[Description("Retrieve book by its globally unique ID.")]publicTask<Book>Book(UserContextcontext,Idid)=>context.Get<Book>(id);[Description("Retrieve author by his/her globally unique ID.")]publicTask<Author>Author(UserContextcontext,Idid)=>context.Get<Author>(id);[Description("Search for books and authors.")]publicConnection<SearchResult>Search(UserContextcontext,[Description("Title or last name.")]NonNull<string>forString,[Description("Only return search results after given cursor.")]Cursor?after,[Description("Return the first N results.")]int?first){returncontext.Search(forString.Value).Select(node=>newSearchResult{Instance=node}).ToConnection(first??5,after);}}

Construct your schema and run your query:

usingGraphQL.Conventions;varengine=GraphQLEngine.New<Query>();varresult=awaitengine.NewExecutor().WithUserContext(userContext).WithDependencyInjector(dependencyInjector).WithRequest(requestBody).Execute();

Examples

More detailed examples can be found in theunit tests.

About

GraphQL Conventions Library for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C#100.0%

[8]ページ先頭

©2009-2025 Movatter.jp