diff --git a/DESIGN.md b/DESIGN.md index d94e2db..96f0e31 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -1,6 +1,6 @@ # Design decisions -This file contains a log of miscellaneous design decisions in genql. +This file contains a log of miscellaneous design decisions in genqlient. ## Types @@ -244,7 +244,7 @@ Instead, we will likely have to do that configuration in comments, which we alre Or, we can figure out how to avoid configuration entirely. This seems short-sighted but may be possible if we can solve for optionality another way and decide collapsing is a non-issue. -**Decision:** We'll configure with comments on the field of the form `# @genql(...)`, syntax TBD but similar to a GraphQL directive. +**Decision:** We'll configure with comments on the field of the form `# @genqlient(...)`, syntax TBD but similar to a GraphQL directive. ### Query function signatures (context/client) @@ -277,6 +277,6 @@ This can all be configurable globally -- say you can decide whether to use conte ### Query extraction (for safelisting) -One thing we want to be able to do is to make it clear exactly what query-document (down to comments and whitespace) we will be sending in the query for the purposes of safelisting and querying based on hash. In the case where you have one query per file, that's easy, just use the whole file. But you may want to share fragments between queries, in which case this is trouble: you either need a way to include fragments from another file (and a defined concatenation order), or you need to have several queries per file, and either have genql extract the right parts (in a defined/reproducible way), or have it send up the full file and the operation name to use (in which case we should still encourage you to not do that unless you're hashing, so that you aren't sending up too much data). We could also allow configuration between the last two options (so if you don't care about hashing/safelisting you can auto-extract). +One thing we want to be able to do is to make it clear exactly what query-document (down to comments and whitespace) we will be sending in the query for the purposes of safelisting and querying based on hash. In the case where you have one query per file, that's easy, just use the whole file. But you may want to share fragments between queries, in which case this is trouble: you either need a way to include fragments from another file (and a defined concatenation order), or you need to have several queries per file, and either have genqlient extract the right parts (in a defined/reproducible way), or have it send up the full file and the operation name to use (in which case we should still encourage you to not do that unless you're hashing, so that you aren't sending up too much data). We could also allow configuration between the last two options (so if you don't care about hashing/safelisting you can auto-extract). We can decide this later once we support fragments and safelisting/hashing; it's fine if that's not available at first. diff --git a/README.md b/README.md index 01c3931..d496071 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ graphqlClient := graphql.NewClient("https://example.com/graphql", http.DefaultCl viewerResp, _ := getViewer(context.Background(), graphqlClient) fmt.Println("you are", viewerResp.Viewer.MyName) -//go:generate go run github.com/Khan/genql +//go:generate go run github.com/Khan/genqlient ``` For a complete working example, see `example/`. diff --git a/example/README.md b/example/README.md index 00b99d3..ca7b92e 100644 --- a/example/README.md +++ b/example/README.md @@ -1,4 +1,4 @@ -# example of genql +# example of genqlient ## Getting a token Get a token from [GitHub](https://github.com/settings/tokens/new) (no scopes needed). @@ -13,7 +13,7 @@ you are Ben Kraft csilvers is Craig Silverstein ``` -## Running genql +## Running genqlient It's already checked in to github, but to generate `generated.go`: ```sh diff --git a/example/caller.go b/example/caller.go index 5ae7485..5be7c70 100644 --- a/example/caller.go +++ b/example/caller.go @@ -6,7 +6,7 @@ import ( "net/http" "os" - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type authedTransport struct { @@ -61,4 +61,4 @@ func Main() { fmt.Println(username, "is", userResp.User.TheirName) } -//go:generate go run github.com/Khan/genql genql.yaml +//go:generate go run github.com/Khan/genqlient genqlient.yaml diff --git a/example/cmd/example/main.go b/example/cmd/example/main.go index a39abcf..823bb68 100644 --- a/example/cmd/example/main.go +++ b/example/cmd/example/main.go @@ -1,7 +1,7 @@ package main import ( - example "github.com/Khan/genql/example" + example "github.com/Khan/genqlient/example" ) func main() { diff --git a/example/generated.go b/example/generated.go index 1e45927..21669ae 100644 --- a/example/generated.go +++ b/example/generated.go @@ -1,11 +1,11 @@ package example -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( "context" - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type getUserResponse struct { diff --git a/example/genql.yaml b/example/genqlient.yaml similarity index 100% rename from example/genql.yaml rename to example/genqlient.yaml diff --git a/generate/example_test.go b/generate/example_test.go index 1976a31..92ca75c 100644 --- a/generate/example_test.go +++ b/generate/example_test.go @@ -15,7 +15,7 @@ func TestGenerateExample(t *testing.T) { } repoRoot := filepath.Dir(filepath.Dir(thisFile)) - configFilename := filepath.Join(repoRoot, "example/genql.yaml") + configFilename := filepath.Join(repoRoot, "example/genqlient.yaml") config, err := ReadAndValidateConfig(configFilename) if err != nil { t.Fatal(err) diff --git a/generate/operation.go.tmpl b/generate/operation.go.tmpl index b332b4c..02bacc6 100644 --- a/generate/operation.go.tmpl +++ b/generate/operation.go.tmpl @@ -1,6 +1,6 @@ package {{.Config.Package}} -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( {{- if .Config.ContextType -}} @@ -10,7 +10,7 @@ import ( "encoding/json" {{end}} - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) {{/* TODO: type-assert that your ctx type implements context.Context */}} diff --git a/generate/testdata/InputObject.graphql.go b/generate/testdata/InputObject.graphql.go index 3b37e44..ac3230f 100644 --- a/generate/testdata/InputObject.graphql.go +++ b/generate/testdata/InputObject.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type InputObjectQueryResponse struct { diff --git a/generate/testdata/InterfaceNoFragments.graphql.go b/generate/testdata/InterfaceNoFragments.graphql.go index 7250611..9423c39 100644 --- a/generate/testdata/InterfaceNoFragments.graphql.go +++ b/generate/testdata/InterfaceNoFragments.graphql.go @@ -1,11 +1,11 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( "encoding/json" - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type InterfaceNoFragmentsQueryResponse struct { diff --git a/generate/testdata/ListInput.graphql.go b/generate/testdata/ListInput.graphql.go index 94d7164..1a04e94 100644 --- a/generate/testdata/ListInput.graphql.go +++ b/generate/testdata/ListInput.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type ListInputQueryResponse struct { diff --git a/generate/testdata/QueryWithAlias.graphql.go b/generate/testdata/QueryWithAlias.graphql.go index 57bef7a..baf8ca5 100644 --- a/generate/testdata/QueryWithAlias.graphql.go +++ b/generate/testdata/QueryWithAlias.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type QueryWithAliasResponse struct { diff --git a/generate/testdata/QueryWithDoubleAlias.graphql.go b/generate/testdata/QueryWithDoubleAlias.graphql.go index 448c7b2..4e767dc 100644 --- a/generate/testdata/QueryWithDoubleAlias.graphql.go +++ b/generate/testdata/QueryWithDoubleAlias.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type QueryWithDoubleAliasResponse struct { diff --git a/generate/testdata/QueryWithEnums.graphql.go b/generate/testdata/QueryWithEnums.graphql.go index c943844..ab3e95c 100644 --- a/generate/testdata/QueryWithEnums.graphql.go +++ b/generate/testdata/QueryWithEnums.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type QueryWithEnumsResponse struct { diff --git a/generate/testdata/QueryWithSlices.graphql.go b/generate/testdata/QueryWithSlices.graphql.go index 4dc684c..6199565 100644 --- a/generate/testdata/QueryWithSlices.graphql.go +++ b/generate/testdata/QueryWithSlices.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type QueryWithSlicesResponse struct { diff --git a/generate/testdata/QueryWithStructs.graphql.go b/generate/testdata/QueryWithStructs.graphql.go index bcdef77..2e6ddf7 100644 --- a/generate/testdata/QueryWithStructs.graphql.go +++ b/generate/testdata/QueryWithStructs.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type QueryWithStructsResponse struct { diff --git a/generate/testdata/SimpleInput.graphql.go b/generate/testdata/SimpleInput.graphql.go index 441e498..0598f0c 100644 --- a/generate/testdata/SimpleInput.graphql.go +++ b/generate/testdata/SimpleInput.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type SimpleInputQueryResponse struct { diff --git a/generate/testdata/SimpleQuery.graphql.go b/generate/testdata/SimpleQuery.graphql.go index 49382e9..6545b47 100644 --- a/generate/testdata/SimpleQuery.graphql.go +++ b/generate/testdata/SimpleQuery.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type SimpleQueryResponse struct { diff --git a/generate/testdata/TypeName.graphql.go b/generate/testdata/TypeName.graphql.go index 4a07f0d..fe5eae7 100644 --- a/generate/testdata/TypeName.graphql.go +++ b/generate/testdata/TypeName.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type TypeNameQueryResponse struct { diff --git a/generate/testdata/UnionNoFragments.graphql.go b/generate/testdata/UnionNoFragments.graphql.go index e47fd38..3907bea 100644 --- a/generate/testdata/UnionNoFragments.graphql.go +++ b/generate/testdata/UnionNoFragments.graphql.go @@ -1,11 +1,11 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( "encoding/json" - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type UnionNoFragmentsQueryRandomLeafArticle struct { diff --git a/generate/testdata/UsesEnumTwice.graphql.go b/generate/testdata/UsesEnumTwice.graphql.go index 97ee3c7..5ba6d75 100644 --- a/generate/testdata/UsesEnumTwice.graphql.go +++ b/generate/testdata/UsesEnumTwice.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type UsesEnumTwiceQueryMeUser struct { diff --git a/generate/testdata/unexported.graphql.go b/generate/testdata/unexported.graphql.go index a88dd63..01c606e 100644 --- a/generate/testdata/unexported.graphql.go +++ b/generate/testdata/unexported.graphql.go @@ -1,9 +1,9 @@ package test -// Code generated by github.com/Khan/genql, DO NOT EDIT. +// Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( - "github.com/Khan/genql/graphql" + "github.com/Khan/genqlient/graphql" ) type unexportedResponse struct { diff --git a/go.mod b/go.mod index d35f243..ae5038e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Khan/genql +module github.com/Khan/genqlient go 1.13 diff --git a/graphql/client.go b/graphql/client.go index 707a320..85804fb 100644 --- a/graphql/client.go +++ b/graphql/client.go @@ -21,7 +21,7 @@ type Client interface { // MakeRequest must make a request to the client's GraphQL API. // // ctx is the context that should be used to make this request. If context - // is disabled in the genql settings, this will be set to + // is disabled in the genqlient settings, this will be set to // context.Background(). // // query is the literal string representing the GraphQL query, e.g. diff --git a/main.go b/main.go index 1d845e1..d086fd8 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ -// package main is at the root to allow "go run github.com/Khan/genql" +// package main is at the root to allow "go run github.com/Khan/genqlient" package main import ( - "github.com/Khan/genql/generate" + "github.com/Khan/genqlient/generate" ) func main() {