Skip to content

Generate Mentat Scripts #711

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
.idea
.idea
go*.tar.gz
4 changes: 4 additions & 0 deletions .mentat/precommit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export PATH=$PATH:/usr/local/go/bin
go fmt ./...
go vet ./...
go test -v -cover -race ./...
4 changes: 4 additions & 0 deletions .mentat/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
curl -OL https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go mod download
26 changes: 14 additions & 12 deletions examples/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ type user struct {
var data map[string]user

/*
Create User object type with fields "id" and "name" by using GraphQLObjectTypeConfig:
- Name: name of object type
- Fields: a map of fields by using GraphQLFields
Setup type of field use GraphQLFieldConfig
Create User object type with fields "id" and "name" by using GraphQLObjectTypeConfig:
- Name: name of object type
- Fields: a map of fields by using GraphQLFields

Setup type of field use GraphQLFieldConfig
*/
var userType = graphql.NewObject(
graphql.ObjectConfig{
Expand All @@ -37,13 +38,14 @@ var userType = graphql.NewObject(
)

/*
Create Query object type with fields "user" has type [userType] by using GraphQLObjectTypeConfig:
- Name: name of object type
- Fields: a map of fields by using GraphQLFields
Setup type of field use GraphQLFieldConfig to define:
- Type: type of field
- Args: arguments to query with current field
- Resolve: function to query data using params from [Args] and return value with current type
Create Query object type with fields "user" has type [userType] by using GraphQLObjectTypeConfig:
- Name: name of object type
- Fields: a map of fields by using GraphQLFields

Setup type of field use GraphQLFieldConfig to define:
- Type: type of field
- Args: arguments to query with current field
- Resolve: function to query data using params from [Args] and return value with current type
*/
var queryType = graphql.NewObject(
graphql.ObjectConfig{
Expand Down Expand Up @@ -97,7 +99,7 @@ func main() {
http.ListenAndServe(":8080", nil)
}

//Helper function to import json from file to map
// Helper function to import json from file to map
func importJSONDataFromFile(fileName string, result interface{}) (isOK bool) {
isOK = true
content, err := ioutil.ReadFile(fileName)
Expand Down
Loading