graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.87k stars 839 forks source link

Add third party library to handle POST/GET request with batch and uploads feature #578

Open jpascal opened 3 years ago

jpascal commented 3 years ago

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

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()