MoienTajik/GraphQL.Tools — dự án backend — đang có 101 sao GitHub trong nhóm Backend. GraphQL.Tools is a GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
GraphQL.Tools is a GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
Features 🌀
GraphQL type to C# class compiler
GraphQL interface to C# interface compiler
GraphQL argument to C# class compiler
GraphQL union to C# class compiler
GraphQL enum to C# enum compiler
Proper C# nullable support
Getting Started
1. Installing GraphQL.Tools
You can install GraphQL.Tools with NuGet Package Manager Console:
Install-Package GraphQL.Tools
Or via the .NET Core command-line interface:
dotnet add package GraphQL.Tools
Either commands, from Package Manager Console or .NET Core CLI, will download and install GraphQL.Tools and all required dependencies.
2. Defining your GraphQL schema
* Important: GraphQL.Tools just accepts .gql and .graphql as valid extensions for GraphQL schema files.
Create a new file called Sample.gql in the root of your project. This is a simple GraphQL schema that demonstrates most of the GraphQL features which you can access it here from the sample project too:
type Query {
getSimple(name: String!): Simple!
simple: Simple!
simples: [Simple]!
nullableSimples: [Simple!]
identity: Identity!
}
# -----------------------------------------------------------
type Simple {
bool: Boolean!
int32: Int!
float: Float!
double: Float!
string: String!
}
# -----------------------------------------------------------
union Identity = EmailIdentity | PhoneNumberIdentity
type EmailIdentity {
value: String!
}
type PhoneNumberIdentity {
value: Float!
}
# -----------------------------------------------------------
enum Color {
RED
GREEN
BLUE
}
# -----------------------------------------------------------
interface Character {
id: Int!
name: String!
}
type Human implements Character {
id: Int!
name: String!
totalCredits: Int
}
type Droid implements Character {
id: Int!
name: String!
primaryFunction: String
}
3. Configuring GraphQL source generator
Open your project .csproj file and add a new ItemGroup section to it that contains a GraphQL element:
Include is the absolute path to our previously created GraphQL schema file that ends with .gql or .graphql.
AdditionalNamespaces are the comma-separated namespaces that need to be included in the generated file to compile properly (Custom types namespaces like DateTime, TimeSpan, ...).
Visitors are the comma-separated name of generators (parsers) that should visit the provided schema file. Currently, these are available visitors:
1. Class
2. Interface
3. Enum
4. Union
5. Argument
4. Done, build the project!
After doing these steps, everything is fine now. Just compile and build the project. The C# file will be generated like this:
using System;
#nullable enable annotations
namespace GraphQL.Tools
{
public partial class Generated
{
public class Query
{
public Simple GetSimple { get; set; }
public Simple Simple { get; set; }
public Simple[] Simples { get; set; }
public Simple[]? NullableSimples { get; set; }
public Identity Identity { get; set; }
}
// -----------------------------------------------------------
public class Simple
{
public bool Bool { get; set; }
public int Int32 { get; set; }
public float Float { get; set; }
public float Double { get; set; }
public string String { get; set; }
}
// -----------------------------------------------------------
public class Identity
{
public EmailIdentity? EmailIdentity { get; set; }
public PhoneNumberIdentity? PhoneNumberIdentity { get; set; }
}
public class EmailIdentity
{
public string Value { get; set; }
}
public class PhoneNumberIdentity
{
public float Value { get; set; }
}
// -----------------------------------------------------------
public enum Color
{
RED,
GREEN,
BLUE
}
// -----------------------------------------------------------
public interface Character
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Human : Character
{
public int Id { get; set; }
public string Name { get; set; }
public int? TotalCredits { get; set; }
}
public class Droid : Character
{
public int Id { get; set; }
public string Name { get; set; }
public string? PrimaryFunction { get; set; }
}
// -----------------------------------------------------------
public class Query_GetSimple_Arguments
{
public string Name { get; set; }
}
}
}
* Side Note: You can view the generated file in $(ProjectDir)\obj\Generated\GraphQL.Tools\GraphQL.Tools.GraphqlCodeGenerator\GraphQL.Tools.g.cs by adding these elements to the PropertyGroup of your .csproj file:
MoienTajik/GraphQL.Tools thuộc nhóm Backend trên TopGit, cùng 9 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về MoienTajik/GraphQL.Tools ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/MoienTajik/GraphQL.Tools là nguồn chính thức.
MoienTajik/GraphQL.Tools có phải mã nguồn mở không?
Có — MoienTajik/GraphQL.Tools phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/MoienTajik/GraphQL.Tools.
MoienTajik/GraphQL.Tools có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho MoienTajik/GraphQL.Tools. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
MoienTajik/GraphQL.Tools dùng license gì?
MoienTajik/GraphQL.Tools phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
MoienTajik/GraphQL.Tools là gì?
MoienTajik/GraphQL.Tools (MoienTajik/GraphQL.Tools) là dự án C# trên GitHub. Theo mô tả gốc: GraphQL.Tools is a GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
Vì sao MoienTajik/GraphQL.Tools được xếp vào nhóm Backend?
TopGit xếp MoienTajik/GraphQL.Tools vào nhóm Backend dựa trên GitHub topics và mô tả của repo (gắn thẻ: "code-generation", "code-generator", "compiler"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
GraphQL.Tools có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về GraphQL.Tools.