Skip to content

Commit

Permalink
Merge pull request #12 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 b37c94a + 4f5928d commit b5fe63d
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 30 deletions.
2 changes: 1 addition & 1 deletion example/user/models/model.go

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

4 changes: 2 additions & 2 deletions example/user/repo/repo.go

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

49 changes: 44 additions & 5 deletions example/user/resolver/operation_gen.go

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

52 changes: 32 additions & 20 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 @@ -13,6 +13,8 @@ extend type Query {
getPost(fuck: String!): Post!
getPosts(fuck: String!): [Post!]!
getPostIds: [ID!]!
testPostId(id: ID!): Post
testPostInt(id: Boolean!): Post
testPostEnum(enum: TestEnum!): String!
testPostInput(input: TestInput!): String!
}
Expand Down
6 changes: 5 additions & 1 deletion graphql/model/generate/tpl/operation_gen.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ func init() {
{{- range $index, $arg := $args }}

{{- if eq $arg.Type.GetRealType.Kind "SCALAR" }}
{{ $arg.Name | lcFirst }}, ok := args["{{ $index }}"].({{ false | $arg.Type.GetGoType }})
pv, e := graphql.Parser.NodeStore.Scalars["{{ $arg.Type.GetRealType.Name }}"].ScalarType.ParseValue(args["{{ $index }}"], nil)
if e != nil {
return nil, e
}
{{ $arg.Name | lcFirst }}, ok := pv.({{ false | $arg.Type.GetGoType }})
if !ok {
return nil, fmt.Errorf("argument: '{{ $arg.Name }}' is not a {{ false | $arg.Type.GetGoType }}, got %T", args["{{ $index }}"])
}
Expand Down
3 changes: 3 additions & 0 deletions template/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ var importRegexMap = map[string]Import{
`handler\.`: {
Path: "github.com/light-speak/lighthouse/handler",
},
`graphql\.`: {
Path: "github.com/light-speak/lighthouse/graphql",
},
}

// AddImportRegex add a new import regex and path to the importRegexMap
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

var Version = "v0.0.2"
var Version = "v0.0.3"

0 comments on commit b5fe63d

Please sign in to comment.