Skip to content

Commit

Permalink
Merge pull request #247 from 99designs/next
Browse files Browse the repository at this point in the history
0.4.0 Release
  • Loading branch information
vektah committed Aug 3, 2018
2 parents 7226e57 + c0be9c9 commit 7b5a3d7
Show file tree
Hide file tree
Showing 155 changed files with 7,184 additions and 10,557 deletions.
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

0 comments on commit 7b5a3d7

Please sign in to comment.