assignment to entry in nil map when uploading a file
- 主要語言
- Go
- 星號
- 10.8k
- 分支
- 1.3k
- 平均合併
- 2 天 36 分鐘
- 30 天內合併 PR
- 26
描述
### What happened?
If the operation field is incorrect during the file upload, a panic is triggered. `assignment to entry in nil map`
The panic occurs in https://github.com/99designs/gqlgen/blob/master/graphql/handler.go#L115
Request:
```
curl --location --request POST 'localhost/graphql' \
--form 'map="{\"1\": [\"variables.file\"]}"' \
--form '1=@"/Users/user_name/image_2021-03-17_14-22-00.png"' \
--form 'operations="{\"query\": \"mutation($file: Upload!) {imageLibraryUpload(input: {name: \\\"image_2021-03-17_14-22-00.png\\\",src: $file}){id}}\"}"'
```
If you add a variable object to the operations, everything will be successful.
```
curl --location --request POST 'localhost/graphql' \
--form 'map="{\"1\": [\"variables.file\"]}"' \
--form '1=@"/Users/user_name/image_2021-03-17_14-22-00.png"' \
--form 'operations="{\"variables\": {\"file\": null}, \"query\": \"mutation($file: Upload!) {imageLibraryUpload(input: {name: \\\"image_2021-03-17_14-22-00.png\\\",src: $file}){id}}\"}"'
```
### What did you expect?
Correct error
### Minimal graphql.schema and models to reproduce
```
type Mutation {
imageLibraryUpload(input: imageLibraryUploadInput!): UploadedImage!
}
type UploadedImage {
id: ID!
srcUrl: String!
}
input imageLibraryUploadInput {
name: String!
src: Upload!
}
```
### versions
- `gqlgen version`? `v0.9.3`
- `go version`? `go1.15.4 darwin/amd64`
- dep or go modules? `go modules`
貢獻指南
評估
這個 Issue 還沒有評估資料。