response.go
1package graphql
2
3import (
4 "context"
5 "encoding/json"
6 "fmt"
7)
8
9type Response struct {
10 Data json.RawMessage `json:"data"`
11 Errors []*Error `json:"errors,omitempty"`
12}
13
14func ErrorResponse(ctx context.Context, messagef string, args ...interface{}) *Response {
15 return &Response{
16 Errors: []*Error{{Message: fmt.Sprintf(messagef, args...)}},
17 }
18}