Skip to content

Commit 429ed61

Browse files
committed
add Conetent-Type multipart/form-data
1 parent c1c8ee7 commit 429ed61

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

handler.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import (
1313
)
1414

1515
const (
16-
ContentTypeJSON = "application/json"
17-
ContentTypeGraphQL = "application/graphql"
18-
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
16+
ContentTypeJSON = "application/json"
17+
ContentTypeGraphQL = "application/graphql"
18+
ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
19+
ContentTypeMultipartFormData = "multipart/form-data"
1920
)
2021

2122
type Handler struct {
22-
Schema *graphql.Schema
23+
Schema *graphql.Schema
2324
pretty bool
2425
graphiql bool
2526
}
@@ -92,7 +93,15 @@ func NewRequestOptions(r *http.Request) *RequestOptions {
9293
}
9394

9495
return &RequestOptions{}
95-
96+
case ContentTypeMultipartFormData:
97+
variables := make(map[string]interface{}, len(r.FormValue("variables")))
98+
variablesStr := r.FormValue("variables")
99+
json.Unmarshal([]byte(variablesStr), &variables)
100+
return &RequestOptions{
101+
Query: r.FormValue("query"),
102+
Variables: variables,
103+
OperationName: r.FormValue("operationName"),
104+
}
96105
case ContentTypeJSON:
97106
fallthrough
98107
default:

0 commit comments

Comments
 (0)