graphiql

package module
v0.0.0-...-07f556f Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: MIT Imports: 10 Imported by: 0

README

go-graphiql

Go http handler to serve the graphiql in-browser IDE.

package main

import (
	"net/http"

	"github.com/mnmtanish/go-graphiql"
)

func main() {
	http.HandleFunc("/graphql", myGraphQLHandler)
	http.HandleFunc("/", graphiql.ServeGraphiQL)
	http.ListenAndServe(":9001", nil)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Tpl      = template.New("index")
	Endpoint = "/graphql"
	T, _     = Tpl.Parse(Data.Content)
)

Functions

func GenResolver

func GenResolver(w io.Writer, options ResolverOptions) (err error)

func ServeGraphQL

func ServeGraphQL(s graphql.Schema) http.HandlerFunc

ServeGraphQL create handler function

func ServeGraphiQL

func ServeGraphiQL(res http.ResponseWriter, req *http.Request)

ServeGraphiQL is a handler function for HTTP servers

Types

type Client

type Client struct {
	Endpoint string
	Header   http.Header
	Client   http.Client
}

Client ...

func NewClient

func NewClient(uri string) (c *Client, err error)

NewClient ...

func (*Client) Send

func (c *Client) Send(req *Request) (res *Response, err error)

Send ...

type GraphQLError

type GraphQLError struct {
	Message string `json:"message"`
}

GraphQLError ...

func (*GraphQLError) Error

func (e *GraphQLError) Error() string

GraphQLError implements error interface

type Request

type Request struct {
	Query     string                 `json:"query"`
	Variables map[string]interface{} `json:"variables"`
}

Request ...

type ResolverOptions

type ResolverOptions struct {
	T       string     `yaml:"t"`
	Name    string     `yaml:"name"`
	Imports []string   `yaml:"imports"`
	Fields  [][]string `yaml:"fields"`
}

type Response

type Response struct {
	Data   *json.RawMessage `json:"data"`
	Errors []GraphQLError   `json:"errors,omitempty"`
}

Response ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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