Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.4.0 Release #247

Merged
merged 87 commits into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
5796d47
Integrate gqlparser
Jul 18, 2018
2692d3e
Merge pull request #197 from vektah/new-parser
vektah Jul 18, 2018
548aed1
Use shared prelude
Jul 19, 2018
c2f1570
Merge pull request #204 from vektah/gqlparser-prelude
vektah Jul 19, 2018
f4d31aa
Update gqlparser for validation locations
Jul 19, 2018
5234374
Merge pull request #206 from vektah/validation-locations
vektah Jul 19, 2018
c3c20f8
Merge remote-tracking branch 'origin/master' into HEAD
Jul 20, 2018
c581017
introduce cobra library
vvakame Jul 21, 2018
eff49d0
support init subcommand
vvakame Jul 21, 2018
87d8fbe
remove unused flag
vvakame Jul 21, 2018
41147f6
update Gopkg.lock
vvakame Jul 21, 2018
39f9dbf
fix error from breaking change
vvakame Jul 21, 2018
08d7f7d
Merge branch 'next' into feat-init
vvakame Jul 21, 2018
138b4ce
Bump gqlparser to get schema validation
Jul 23, 2018
6ba508f
Merge pull request #214 from vektah/gqlparser-schema-validation
vektah Jul 23, 2018
bab7abb
Merge pull request #210 from vektah/feat-init
vektah Jul 23, 2018
ebfde10
Pass request context through to CollectFields
Jul 19, 2018
ea0f821
Add skip/include directive implementation
Jul 20, 2018
cbfae3d
Add skip/include test cases
Jul 20, 2018
ce17cd9
Add default value test case
Jul 23, 2018
c7ff320
Update gqlparser version to include default resolution
Jul 23, 2018
d02d17a
Add method for generating method name from field
creativej Jul 23, 2018
a69071e
Pass context to CollectFields instead of RequestContext
Jul 23, 2018
ffe4265
Merge pull request #208 from vektah/directives-skip-include
Jul 23, 2018
3870896
Stop generating two types of resolvers
creativej Jul 23, 2018
1ba61fc
Update test & examples to use new resolver pattern
creativej Jul 23, 2018
40989b1
turn back -race option
vvakame Jul 23, 2018
1a3e4e9
Merge pull request #220 from vektah/feat-race
vektah Jul 23, 2018
f67f839
Merge pull request #218 from vektah/remove-old-resolvers
creativej Jul 24, 2018
b512176
Run resolver middleware for all fields
Jul 23, 2018
97f1318
Remove comment about ResolverMiddleware
Jul 23, 2018
ec928ca
Regenerate examples
Jul 23, 2018
7292be7
Rename CastType to AliasedType
Jul 23, 2018
0fa7977
Merge pull request #217 from vektah/resolver-middleware-all
Jul 24, 2018
66593ff
Merge remote-tracking branch 'origin/master' into HEAD
Jul 25, 2018
764c6fd
Refactor ResolverMiddleware to FieldMiddleware
Jul 24, 2018
d6813f6
Generarte
Jul 24, 2018
69e790c
Add *Field to CollectedField
Jul 25, 2018
0924206
Add Directives to Build
Jul 25, 2018
2748a19
Require Config object into NewExecutableSchema
Jul 25, 2018
0e16f1f
Generate FieldMiddleware
Jul 25, 2018
8416324
Regenerate
Jul 25, 2018
73a8e3a
Fix some issues with directive middlewares
Jul 25, 2018
5dc104e
Add middleware example for Todo
Jul 25, 2018
0ec918b
Switch GoName to Name|ucFirst
Jul 26, 2018
803711e
Merge pull request #221 from vektah/middleware-stack
Jul 26, 2018
078bc98
Fixing init command
creativej Jul 26, 2018
7031264
Merge pull request #229 from vektah/fix-init-command
creativej Jul 30, 2018
58831ac
Generate resolver if configured
creativej Jul 26, 2018
df95f00
Generate code after init
creativej Jul 26, 2018
ffee020
Merge pull request #235 from vektah/generate-resolver-on-init
creativej Jul 31, 2018
69eab93
Add model field mapping
vvakame Jul 31, 2018
f7f6f91
Make more lint friendly
vvakame Jul 31, 2018
108bb6b
Rename govarname to modelField
vvakame Jul 31, 2018
121e8db
Generate server on running init
creativej Jul 31, 2018
d6a7625
Add missing variable validation
vektah Jul 31, 2018
600f467
Merge pull request #238 from vektah/variable-validation
vektah Aug 1, 2018
17bcb32
Merge pull request #236 from vektah/generate-handler-on-init
creativej Aug 1, 2018
d7e2466
Add method support
vvakame Aug 1, 2018
353319c
Refactor GoVarName and GoMethodName to GoFieldName etc...
vvakame Aug 1, 2018
bf43ab3
Merge branch 'next' into feat-fieldmapping
vvakame Aug 1, 2018
4fb721a
address comment
vvakame Aug 1, 2018
6b53238
Merge pull request #237 from vektah/feat-fieldmapping
vektah Aug 1, 2018
64ef057
Use fonts from golang styleguide
Aug 1, 2018
17bfa2c
Merge pull request #240 from vektah/doc-fonts
vektah Aug 1, 2018
c3fa1a5
Merge branch 'next' into feat-lintfree
vvakame Aug 1, 2018
19b5817
Merge remote-tracking branch 'origin/master' into HEAD
Aug 1, 2018
f78a604
Merge pull request #241 from vektah/feat-lintfree
vektah Aug 2, 2018
4f37d17
Add directive args
Aug 1, 2018
3bef596
regenerate
Aug 1, 2018
191c8ba
Merge pull request #239 from vektah/directive-args
vektah Aug 2, 2018
d2265f3
Add implicit value to array coercion
Aug 2, 2018
9397920
Add field name config docs
Aug 2, 2018
b38c580
Return the correct mutation & subscription type
creativej Aug 2, 2018
bc204c6
Update getting started guide
Aug 2, 2018
62d4c8a
Ignore __ fields in instrospection
creativej Aug 2, 2018
e44d798
Add directives docs
Aug 2, 2018
ef208c7
add docs for resolver generation
Aug 2, 2018
90b4076
Merge pull request #246 from vektah/fix-introspection
vektah Aug 2, 2018
825840a
Merge pull request #244 from vektah/array-coercion
vektah Aug 2, 2018
c555f54
Merge pull request #245 from vektah/new-feature-docs
vektah Aug 2, 2018
95fe07f
use json.Decoder.UseNumber() when unmarshalling vars
Aug 2, 2018
07b7e6c
Merge pull request #248 from 99designs/json-usenumber
vektah Aug 2, 2018
658a24d
Move doc site
Aug 3, 2018
f042328
Merge pull request #252 from 99designs/move-doc-site
vektah Aug 3, 2018
4361401
Rewrite import paths
Aug 3, 2018
c0be9c9
Merge pull request #251 from 99designs/rewrite-imports
vektah Aug 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
docker:
- image: golang:1.9
working_directory: /go/src/github.com/vektah/gqlgen
working_directory: /go/src/github.com/99designs/gqlgen
steps: &steps
- checkout
- run: >
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/internal/tests/testdata/graphql-js
/vendor
/docs/public
/example/chat/node_modules
/example/chat/package-lock.json
/codegen/testdata/gen
/codegen/tests/gen

.idea/
53 changes: 53 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ See the [docs](https://gqlgen.com/) for a getting started guide.
github.com/99designs/gqlgen soon. The next few weeks is going to see some heavy work pushing the new parser and
directive support forward. Expect exciting things!

You can follow along on the [project board](https://github.com/vektah/gqlgen/projects/1).
You can follow along on the [project board](https://github.com/99designs/gqlgen/projects/1).

### Feature comparison

| | [gqlgen](https://github.com/vektah/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) |
| | [gqlgen](https://github.com/99designs/gqlgen) | [gophers](https://github.com/graph-gophers/graphql-go) | [graphql-go](https://github.com/graphql-go/graphql) | [thunder](https://github.com/samsarahq/thunder) |
| --------: | :-------- | :-------- | :-------- | :-------- |
| Kind | schema first | schema first | run time types | struct first |
| Boilerplate | less | more | more | some |
| Docs | [docs](https://gqlgen.com) & [examples](https://github.com/vektah/gqlgen/tree/master/example) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)|
| Docs | [docs](https://gqlgen.com) & [examples](https://github.com/99designs/gqlgen/tree/master/example) | [examples](https://github.com/graph-gophers/graphql-go/tree/master/example/starwars) | [examples](https://github.com/graphql-go/graphql/tree/master/examples) | [examples](https://github.com/samsarahq/thunder/tree/master/example)|
| Query | :+1: | :+1: | :+1: | :+1: |
| Mutation | :+1: | :construction: [pr](https://github.com/graph-gophers/graphql-go/pull/182) | :+1: | :+1: |
| Subscription | :+1: | :construction: [pr](https://github.com/graph-gophers/graphql-go/pull/132) | :no_entry: [is](https://github.com/graphql-go/graphql/issues/207) | :+1: |
Expand All @@ -28,7 +28,7 @@ You can follow along on the [project board](https://github.com/vektah/gqlgen/pro
| Interfaces | :+1: | :+1: | :+1: | :no_entry: [is](https://github.com/samsarahq/thunder/issues/78) |
| Generated Enums | :+1: | :no_entry: | :no_entry: | :no_entry: |
| Generated Inputs | :+1: | :no_entry: | :no_entry: | :no_entry: |
| Stitching gql | :clock1: [is](https://github.com/vektah/gqlgen/issues/5) | :no_entry: | :no_entry: | :no_entry: |
| Stitching gql | :clock1: [is](https://github.com/99designs/gqlgen/issues/5) | :no_entry: | :no_entry: | :no_entry: |
| Opentracing | :+1: | :+1: | :no_entry: | :scissors:[pr](https://github.com/samsarahq/thunder/pull/77) |
| Hooks for error logging | :+1: | :no_entry: | :no_entry: | :no_entry: |
| Dataloading | :+1: | :+1: | :no_entry: | :warning: |
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "{build}"
# Source Config

skip_branch_with_pr: true
clone_folder: c:\gopath\src\github.com\vektah\gqlgen
clone_folder: c:\gopath\src\github.com\99designs\gqlgen

# Build host

Expand All @@ -13,7 +13,7 @@ environment:
PATH: '%PATH%;c:\gopath\bin'

branches:
only: ["master"]
only: ["master", "next"]

init:
- git config --global core.autocrlf input
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http/httptest"
"testing"

"github.com/99designs/gqlgen/client"
"github.com/stretchr/testify/require"
"github.com/vektah/gqlgen/client"
)

func TestClient(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions client/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/gorilla/websocket"
"github.com/vektah/gqlgen/neelance/errors"
"github.com/vektah/gqlparser/gqlerror"
)

const (
Expand Down Expand Up @@ -83,7 +83,7 @@ func (p *Client) Websocket(query string, options ...Option) *Subscription {
}

if respDataRaw["errors"] != nil {
var errs []*errors.QueryError
var errs []*gqlerror.Error
if err = unpack(respDataRaw["errors"], errs); err != nil {
return err
}
Expand Down
115 changes: 115 additions & 0 deletions cmd/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package cmd

import (
"fmt"
"io/ioutil"
"os"

"github.com/99designs/gqlgen/codegen"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

func init() {
rootCmd.AddCommand(genCmd)
}

var genCmd = &cobra.Command{
Use: "gen",
Short: "Generate models & resolvers .go",
Long: "",
Run: func(cmd *cobra.Command, args []string) {
var config *codegen.Config
var err error
if configFilename != "" {
config, err = codegen.LoadConfig(configFilename)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
} else {
config, err = codegen.LoadConfigFromDefaultLocations()
if os.IsNotExist(errors.Cause(err)) {
config = codegen.DefaultConfig()
} else if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
}

// overwrite by commandline options
var emitYamlGuidance bool
if schemaFilename != "" {
config.SchemaFilename = schemaFilename
}
if models != "" {
config.Model.Filename = models
}
if output != "" {
config.Exec.Filename = output
}
if packageName != "" {
config.Exec.Package = packageName
}
if modelPackageName != "" {
config.Model.Package = modelPackageName
}
if typemap != "" {
config.Models = loadModelMap()
emitYamlGuidance = true
}

schemaRaw, err := ioutil.ReadFile(config.SchemaFilename)
if err != nil {
fmt.Fprintln(os.Stderr, "unable to open schema: "+err.Error())
os.Exit(1)
}
config.SchemaStr = string(schemaRaw)

if err = config.Check(); err != nil {
fmt.Fprintln(os.Stderr, "invalid config format: "+err.Error())
os.Exit(1)
}

if emitYamlGuidance {
var b []byte
b, err = yaml.Marshal(config)
if err != nil {
fmt.Fprintln(os.Stderr, "unable to marshal yaml: "+err.Error())
os.Exit(1)
}

fmt.Fprintf(os.Stderr, "DEPRECATION WARNING: we are moving away from the json typemap, instead create a gqlgen.yml with the following content:\n\n%s\n", string(b))
}

err = codegen.Generate(*config)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(2)
}
},
}

func loadModelMap() codegen.TypeMap {
var goTypes map[string]string
b, err := ioutil.ReadFile(typemap)
if err != nil {
fmt.Fprintln(os.Stderr, "unable to open typemap: "+err.Error())
return nil
}

if err = yaml.Unmarshal(b, &goTypes); err != nil {
fmt.Fprintln(os.Stderr, "unable to parse typemap: "+err.Error())
os.Exit(1)
}

typeMap := make(codegen.TypeMap)
for typeName, entityPath := range goTypes {
typeMap[typeName] = codegen.TypeMapEntry{
Model: entityPath,
}
}

return typeMap
}
Loading