Skip to content

Commit

Permalink
Merge pull request #10 from light-speak/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
light-speak authored Nov 1, 2024
2 parents df8ba07 + ab9a51d commit 4a61625
Show file tree
Hide file tree
Showing 22 changed files with 543 additions and 128 deletions.
3 changes: 3 additions & 0 deletions command/cli/generate/initialize/two/tpl/resolver.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
func init() {
}
36 changes: 36 additions & 0 deletions command/cli/generate/initialize/two/two.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package two

import (
"embed"
"fmt"
"path/filepath"

"github.com/light-speak/lighthouse/template"
Expand All @@ -20,6 +21,10 @@ func Run(module string) error {
if err != nil {
return err
}
err = initResolver()
if err != nil {
return err
}
err = initService()
if err != nil {
return err
Expand Down Expand Up @@ -56,6 +61,23 @@ func initRepo() error {
return template.Render(options)
}

func initResolver() error {
resolverTemplate, err := twoFs.ReadFile("tpl/resolver.tpl")
if err != nil {
return err
}
options := &template.Options{
Path: filepath.Join(projectName, "resolver"),
Template: string(resolverTemplate),
FileName: "resolver",
FileExt: "go",
Package: "resolver",
Editable: true,
SkipIfExists: true,
}
return template.Render(options)
}

func initService() error {
serviceTemplate, err := twoFs.ReadFile("tpl/service.tpl")
if err != nil {
Expand All @@ -69,6 +91,20 @@ func initService() error {
Package: "service",
Editable: true,
SkipIfExists: true,
Imports: []*template.Import{
{
Path: fmt.Sprintf("%s/resolver", projectModule),
Alias: "_",
},
{
Path: fmt.Sprintf("%s/repo", projectModule),
Alias: "_",
},
{
Path: fmt.Sprintf("%s/models", projectModule),
Alias: "_",
},
},
}
return template.Render(options)
}
Expand Down
30 changes: 15 additions & 15 deletions example/user/models/model.go

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

66 changes: 33 additions & 33 deletions example/user/repo/repo.go

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

53 changes: 43 additions & 10 deletions example/user/resolver/operation_gen.go

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

45 changes: 30 additions & 15 deletions example/user/resolver/query.go

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

2 changes: 2 additions & 0 deletions example/user/schema/post.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ extend type Query {
posts(id: [ID!]! @in, user_id: ID! @neq): [Post!]! @find
post(id: ID! @eq): Post! @first
getPost(fuck: String!): Post!
getPosts(fuck: String!): [Post!]!
getPostIds: [ID!]!
testPostEnum(enum: TestEnum!): String!
testPostInput(input: TestInput!): String!
}
Expand Down
Loading

0 comments on commit 4a61625

Please sign in to comment.