graphql

package
v0.0.0-...-3871cc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserGraphQL = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "User",
		Fields: graphql.Fields{
			"id": &graphql.Field{
				Type: graphql.String,
			},
			"name": &graphql.Field{
				Type: graphql.String,
			},
			"email": &graphql.Field{
				Type: graphql.String,
			},
			"phone": &graphql.Field{
				Type: graphql.String,
			},
			"address": &graphql.Field{
				Type: graphql.String,
			},
			"created_at": &graphql.Field{
				Type: graphql.DateTime,
			},
			"updated_at": &graphql.Field{
				Type: graphql.DateTime,
			},
		},
	},
)

UserGraphQL holds user information with graphql object

View Source
var UserListGraphQL = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "UserList",
		Fields: graphql.Fields{
			"list": &graphql.Field{
				Type: graphql.NewList(UserGraphQL),
			},
			"page": &graphql.Field{
				Type: graphql.Int,
			},
			"per_page": &graphql.Field{
				Type: graphql.Int,
			},
			"total_page": &graphql.Field{
				Type: graphql.Int,
			},
			"total_data": &graphql.Field{
				Type: graphql.Int,
			},
		},
	},
)

UserListGraphQL holds user list information with graphql object

Functions

func Handler

func Handler(userSvc user.Service) gin.HandlerFunc

Handler initializes the graphql middleware.

Types

type Resolver

type Resolver interface {
	List(params graphql.ResolveParams) (interface{}, error)
	Detail(params graphql.ResolveParams) (interface{}, error)

	Update(params graphql.ResolveParams) (interface{}, error)
	Create(params graphql.ResolveParams) (interface{}, error)
	Delete(params graphql.ResolveParams) (interface{}, error)
}

Resolver represent the graphql resolver

func NewResolver

func NewResolver(svc usr.Service) Resolver

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema is struct which has method for Query and Mutation. Please init this struct using constructor function.

func NewSchema

func NewSchema(userResolver Resolver) Schema

NewSchema initializes Schema struct which takes resolver as the argument.

func (Schema) Mutation

func (s Schema) Mutation() *graphql.Object

Mutation initializes config schema mutation for graphql server.

func (Schema) Query

func (s Schema) Query() *graphql.Object

Query initializes config schema query for graphql server.

type UserList

type UserList struct {
	List      []*model.UserModel
	Page      int
	PerPage   int
	TotalPage int
	TotalData int
}

UserList holds information of users list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL