cli/shurcooL-graphql được TopGit xếp vào nhóm dự án mã nguồn mở, với 29 sao trên GitHub, viết chủ yếu bằng Go. Package graphql provides a GraphQL client implementation.
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.
Package graphql provides a GraphQL client implementation, and is forked from https://github.com/shurcooL/graphql.
Installation
go get -u github.com/cli/shurcooL-graphql
Usage
Construct a GraphQL client, specifying the GraphQL server URL. Then, you can use it to make GraphQL queries and mutations.
client := graphql.NewClient("https://example.com/graphql", nil)
// Use client...
Authentication
Some GraphQL servers may require authentication. The graphql package does not directly handle authentication. Instead, when creating a new client, you're expected to pass an http.Client that performs authentication. The easiest and recommended way to do this is to use the golang.org/x/oauth2 package. You'll need an OAuth token with the right scopes. Then:
However, that'll only work if the arguments are constant and known in advance. Otherwise, you will need to make use of variables. Replace the constants in the struct field tag with variable names:
var q struct {
Human struct {
Name graphql.String
Height graphql.Float `graphql:"height(unit: $unit)"`
} `graphql:"human(id: $id)"`
}
Mutations often require information that you can only find out by performing a query first. Let's suppose you've already done that.
For example, to make the following GraphQL mutation:
mutation($ep: Episode!, $review: ReviewInput!) {
createReview(episode: $ep, review: $review) {
stars
commentary
}
}
variables {
"ep": "JEDI",
"review": {
"stars": 5,
"commentary": "This is a great movie!"
}
}
You can define:
var m struct {
CreateReview struct {
Stars graphql.Int
Commentary graphql.String
} `graphql:"createReview(episode: $ep, review: $review)"`
}
variables := map[string]any{
"ep": starwars.Episode("JEDI"),
"review": starwars.ReviewInput{
Stars: graphql.Int(5),
Commentary: graphql.String("This is a great movie!"),
},
}
Then call client.Mutate:
err := client.Mutate(context.Background(), &m, variables)
if err != nil {
// Handle error.
}
fmt.Printf("Created a %v star review: %v\n", m.CreateReview.Stars, m.CreateReview.Commentary)
// Output:
// Created a 5 star review: This is a great movie!
cli/shurcooL-graphql có 29 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/cli/shurcooL-graphql. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
cli/shurcooL-graphql có phải mã nguồn mở không?
Có — cli/shurcooL-graphql 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/cli/shurcooL-graphql.
cli/shurcooL-graphql có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho cli/shurcooL-graphql. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
cli/shurcooL-graphql là gì?
cli/shurcooL-graphql (cli/shurcooL-graphql) là dự án Go trên GitHub. Theo mô tả gốc: Package graphql provides a GraphQL client implementation.
Đọc thêm về cli/shurcooL-graphql ở đâ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/cli/shurcooL-graphql là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
shurcooL-graphql 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ề shurcooL-graphql.