handler

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 8 Imported by: 1

README

graphql-upload

GitHub Actions status

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various golang GraphQL servers.

Installation

go get github.com/jpascal/graphql-upload

Usage

server := &http.Server{
	Addr: "0.0.0.0:5000", 
	Handler: handler.New(func(request *handler.Request) interface{} {
		return graphql.Do(graphql.Params{
			RequestString:  request.Query,
			OperationName:  request.OperationName,
			VariableValues: request.Variables,
			Schema:         schema.New(),
			Context:        request.Context,
		})
	}, &handler.Config {MaxBodySize: 1024}),
}
    server.ListenAndServe()

Contributing

  1. Fork it ( https://github.com/jpascal/graphql-upload/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxBodySize int64
}

type Executor

type Executor func(request *Request) interface{}

type Factory

type Factory func(http.ResponseWriter, *http.Request) interface{}

type File

type File struct {
	File     multipart.File
	Filename string
	Size     int64
}

type Handler

type Handler struct {
	MaxBodySize int64 // in bytes
	Executor    Executor
	Client      bool
}

func New

func New(executor Executor, config *Config) *Handler

func (*Handler) ServeHTTP

func (self *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Request

type Request struct {
	OperationName string                 `json:"operationName"`
	Query         string                 `json:"query"`
	Variables     map[string]interface{} `json:"variables"`
	Context       context.Context
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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