Skip to content

Commit

Permalink
fix: Multiple fixes in substance library resolve issues with code gen…
Browse files Browse the repository at this point in the history
…eration
  • Loading branch information
ahmedalhulaibi committed Mar 9, 2018
1 parent 9235861 commit 5f56080
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 179 deletions.
2 changes: 1 addition & 1 deletion Gopkg.lock

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

11 changes: 7 additions & 4 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"

"github.com/ahmedalhulaibi/substance/substancegen/generators/genutil"
"github.com/ahmedalhulaibi/substance/substancegen/generators/gorm"
"github.com/ahmedalhulaibi/substance/substancegen/generators/gostruct"
"github.com/ahmedalhulaibi/substance/substancegen/generators/graphqlgo"
Expand Down Expand Up @@ -45,7 +46,7 @@ Run 'graphqlator init' before running 'graphqlator generate'`,
gqlPkg := getGraphqlatorPkgFile()
gqlGen := substancegen.SubstanceGenPlugins["graphql-go"].(graphqlgo.Gql)
gqlObjectTypes := gqlGen.GetObjectTypesFunc(gqlPkg.DatabaseType, gqlPkg.ConnectionString, gqlPkg.TableNames)
gqlGen.AddJSONTagsToProperties(gqlObjectTypes)
genutil.AddJSONTagsToProperties(gqlObjectTypes)

if gqlPkg.GenMode == "graphql-go" {
if !updateGormQueries && !updateGqlFields && !updateGqlTypes && !updateModel && !updateSchema && !updateMain && !updateAll {
Expand All @@ -57,7 +58,7 @@ Run 'graphqlator init' before running 'graphqlator generate'`,
var mainFileBuffer bytes.Buffer
gqlGen.GenPackageImports(gqlPkg.DatabaseType, &mainFileBuffer)
mainFileBuffer.WriteString(graphqlgo.GraphqlGoExecuteQueryFunc)
gqlGen.GenGraphqlGoMainFunc(gqlPkg.DatabaseType, gqlPkg.ConnectionString, gqlObjectTypes, &mainFileBuffer)
graphqlgo.GenGraphqlGoMainFunc(gqlPkg.DatabaseType, gqlPkg.ConnectionString, gqlObjectTypes, &mainFileBuffer)
_, err := mainFile.Write(mainFileBuffer.Bytes())
if err != nil {
fmt.Println(err.Error())
Expand Down Expand Up @@ -101,7 +102,9 @@ Run 'graphqlator init' before running 'graphqlator generate'`,

var gqlFieldsFileBuff bytes.Buffer
gqlGen.GenPackageImports(gqlPkg.DatabaseType, &gqlFieldsFileBuff)
gqlGen.GenGraphqlGoRootQueryFunc(gqlObjectTypes, &gqlFieldsFileBuff)

gqlFieldsFileBufferTemp := graphqlgo.GenGraphqlGoFieldsFunc(gqlObjectTypes)
gqlFieldsFileBuff.Write(gqlFieldsFileBufferTemp.Bytes())
_, err := gqlFieldsFile.Write(gqlFieldsFileBuff.Bytes())
if err != nil {
fmt.Println(err.Error())
Expand All @@ -126,7 +129,7 @@ Run 'graphqlator init' before running 'graphqlator generate'`,

if updateSchema || updateAll {
graphqlSchemaFile := createFile("schema.graphql", true)
graphqlSchemaFileBuffer := gqlGen.OutputGraphqlSchema(gqlObjectTypes)
graphqlSchemaFileBuffer := graphqlgo.OutputGraphqlSchema(gqlObjectTypes)
_, err := graphqlSchemaFile.Write(graphqlSchemaFileBuffer.Bytes())
if err != nil {
fmt.Println(err.Error())
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/ahmedalhulaibi/substance/.travis.yml

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

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

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

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

0 comments on commit 5f56080

Please sign in to comment.