diff --git a/handler.go b/handler.go index b9a647c..5627900 100644 --- a/handler.go +++ b/handler.go @@ -15,9 +15,10 @@ import ( ) const ( - ContentTypeJSON = "application/json" - ContentTypeGraphQL = "application/graphql" - ContentTypeFormURLEncoded = "application/x-www-form-urlencoded" + ContentTypeJSON = "application/json" + ContentTypeGraphQL = "application/graphql" + ContentTypeFormURLEncoded = "application/x-www-form-urlencoded" + ContentTypeMultipartFormData = "multipart/form-data" ) type ResultCallbackFn func(ctx context.Context, params *graphql.Params, result *graphql.Result, responseBody []byte) @@ -101,7 +102,15 @@ func NewRequestOptions(r *http.Request) *RequestOptions { } return &RequestOptions{} - + case ContentTypeMultipartFormData: + variables := make(map[string]interface{}, len(r.FormValue("variables"))) + variablesStr := r.FormValue("variables") + json.Unmarshal([]byte(variablesStr), &variables) + return &RequestOptions{ + Query: r.FormValue("query"), + Variables: variables, + OperationName: r.FormValue("operationName"), + } case ContentTypeJSON: fallthrough default: