stash/vendor/github.com/Yamashou/gqlgenc
SmallCoccinelle 45f700d6ea
Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443)
* Upgrade gqlgen to v0.17.2

This enables builds on Go 1.18. github.com/vektah/gqlparser is upgraded
to the newest version too.

Getting this to work is a bit of a hazzle. I had to first remove
vendoring from the repository, perform the upgrade and then re-introduce
the vendor directory. I think gqlgens analysis went wrong for some
reason on the upgrade. It would seem a clean-room installation fixed it.

* Bump project to 1.18

* Update all packages, address gqlgenc breaking changes

* Let `go mod tidy` handle the go.mod file

* Upgrade linter to 1.45.2

* Introduce v1.45.2 of the linter

The linter now correctly warns on `strings.Title` because it isn't
unicode-aware. Fix this by using the suggested fix from x/text/cases
to produce unicode-aware strings.

The mapping isn't entirely 1-1 as this new approach has a larger iface:
it spans all of unicode rather than just ASCII. It coincides for ASCII
however, so things should be largely the same.

* Ready ourselves for errchkjson and contextcheck.

* Revert dockerfile golang version changes for now

Co-authored-by: Kermie <kermie@isinthe.house>
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2022-04-02 18:08:14 +11:00
..
client Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
clientgen Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
clientgenv2 Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
config Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
generator Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
graphqljson Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
introspection Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
.gitignore Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
.golangci.yml Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
LICENSE Stash box client interface (#751) 2020-09-17 19:57:18 +10:00
Makefile Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
README.md Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
TESTING.md Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00
main.go Support Go 1.18: Upgrade gqlgen to v0.17.2 (#2443) 2022-04-02 18:08:14 +11:00

README.md

gqlgenc

What is gqlgenc ?

This is Go library for building GraphQL client with gqlgen

Motivation

Now, if you build GraphQL api client for Go, have choice:

These libraries are very simple and easy to handle. However, as I work with gqlgen and graphql-code-generator every day, I find out the beauty of automatic generation. So I want to automatically generate types.

Installation

go get -u github.com/Yamashou/gqlgenc

How to use

Client Codes Only

gqlgenc base is gqlgen with plugins. So the setting is yaml in each format.
gqlgenc can be configured using a .gqlgenc.yml file

Load a schema from a remote server:

model:
  package: generated
  filename: ./models_gen.go # https://github.com/99designs/gqlgen/tree/master/plugin/modelgen
client:
  package: generated
  filename: ./client.go # Where should any generated client go?
models:
  Int:
    model: github.com/99designs/gqlgen/graphql.Int64
  Date:
    model: github.com/99designs/gqlgen/graphql.Time
endpoint:
  url: https://api.annict.com/graphql # Where do you want to send your request?
  headers: # If you need header for getting introspection query, set it
    Authorization: "Bearer ${ANNICT_KEY}" # support environment variables
query:
  - "./query/*.graphql" # Where are all the query files located?

Load a schema from a local file:

model:
  package: generated
  filename: ./models_gen.go # https://github.com/99designs/gqlgen/tree/master/plugin/modelgen
client:
  package: generated
  filename: ./client.go # Where should any generated client go?
models:
  Int:
    model: github.com/99designs/gqlgen/graphql.Int64
  Date:
    model: github.com/99designs/gqlgen/graphql.Time
schema:
  - "schema/**/*.graphql" # Where are all the schema files located?
query:
  - "./query/*.graphql" # Where are all the query files located?

Execute the following command on same directory for .gqlgenc.yml

gqlgenc

With gqlgen

Do this when creating a server and client for Go. You create your own entrypoint for gqlgen. This use case is very useful for testing your server.

package main

import (
	"fmt"
	"os"

	"github.com/Yamashou/gqlgenc/clientgen"

	"github.com/99designs/gqlgen/api"
	"github.com/99designs/gqlgen/codegen/config"
)

func main() {
	cfg, err := config.LoadConfigFromDefaultLocations()
	if err != nil {
		fmt.Fprintln(os.Stderr, "failed to load config", err.Error())
		os.Exit(2)
	}
	queries := []string{"client.query", "fragemt.query"}
	clientPackage := config.PackageConfig{
		Filename: "./client.go",
		Package:  "gen",
	}

	clientPlugin := clientgen.New(queries, clientPackage)
	err = api.Generate(cfg,
		api.AddPlugin(clientPlugin),
	)
	if err != nil {
		fmt.Fprintln(os.Stderr, err.Error())
		os.Exit(3)
	}
}

Documents

Comments

Japanese Comments

These codes have Japanese comments. Replace with English.

Subscription

This client does not support subscription. If you need a subscription, please create an issue or pull request.

Pre-conditions

clientgen is created based on modelgen. So if you don't have a modelgen, it may be a mysterious move.