gos
github.com/incu6us/gostruct2graphql
go get github.com/incu6us/gostruct2graphql
gos

github.com/incu6us/gostruct2graphql

Go structure to GraphQL object

go get github.com/incu6us/gostruct2graphql
Readme

gostruct2graphql

Put your struct to structs/structs.go and choose it in the main method of main.go, like:

...
func main() {

    getRootDescription(structs.Repository{})
    getRootDescription(structs.Test{})

}

then, run the app:

go run main.go

Response

// Generated by gostruct2graphql
RepositoryGqlType := graphql.NewList(graphql.NewObject(graphql.ObjectConfig{
          Name: "Repository",
          Fields: graphql.Fields{"CacheMaxSeconds": &graphql.Field{
        Type: graphql.Int,
      },"CurrentTime": &graphql.Field{
        Type: graphql.Int,
      },"Doc": &graphql.Field{
                Type: graphql.NewObject(graphql.ObjectConfig{
                    Name: "Doc",
                    Fields: graphql.Fields{"TropData": &graphql.Field{
                Type: graphql.NewObject(graphql.ObjectConfig{
                    Name: "TropData",
                    Fields: graphql.Fields{"Two016": &graphql.Field{
                Type: graphql.NewList(graphql.NewObject(graphql.ObjectConfig{
                    Name: "Two016",
                    Fields: graphql.Fields{"Active": &graphql.Field{
        Type: graphql.Boolean,
      },"Category": &graphql.Field{
        Type: graphql.String,
      },"Status": &graphql.Field{
        Type: graphql.String,
      },"TropID": &graphql.Field{
        Type: graphql.String,
      },"TropName": &graphql.Field{
        Type: graphql.String,
      },},
      })),
    },},
      }),
    },"TropHdr": &graphql.Field{
                Type: graphql.NewObject(graphql.ObjectConfig{
                    Name: "TropHdr",
                    Fields: graphql.Fields{"TNum": &graphql.Field{
        Type: graphql.Int,
      },},
      }),
    },},
      }),
    },"GeneratedTime": &graphql.Field{
        Type: graphql.Int,
      },"ID": &graphql.Field{
        Type: graphql.String,
      },"Status": &graphql.Field{
        Type: graphql.Int,
      },},
}))

// Generated by gostruct2graphql
TestGqlType := graphql.NewObject(graphql.ObjectConfig{
          Name: "Test",
          Fields: graphql.Fields{"Stringer": &graphql.Field{
        Type: graphql.String,
      },},
})

GitHub Stars

11

LAST COMMIT

5yrs ago

MAINTAINERS

0

CONTRIBUTORS

1

OPEN ISSUES

1

OPEN PRs

1
VersionTagPublished
v0.0.0-20161221121048-f957fe15cc70
2yrs ago
No alternatives found
No tutorials found
Add a tutorial