Repository: Khan/genqlient
Pull request #347 (2024-08-16 23:47:26)

Subscription support
**Added [support for graphQL subscriptions](https://github.com/Khan/genqlient/issues/199).**

- Using `graphql.NewClientUsingWebSocket()`, the returned `graphql.WebSocketClient` will be able to subscribe to graphQL endpoints.
- Implementation does not depend on a specific websocket package, but it is similar to [github.com/gorilla/websocket](https://github.com/gorilla/websocket) (this package is also used to create a client in the tests).

Note: this is just #294 with main merged and a few small docs tweaks. See there for review discussion etc.

Fixes #199.

I have:
- [x] Written a clear PR title and description (above)
- [x] Signed the [Khan Academy CLA](https://www.khanacademy.org/r/cla)
- [x] Added tests covering my changes, if applicable
- [x] Included a link to the issue fixed, if applicable
- [x] Included documentation, for new features
- [x] Added an entry to the changelog



Patch:
diff --git a/.golangci.yml b/.golangci.yml
index 0446dda..13192e9 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -54,6 +54,7 @@ linters-settings:
           - gopkg.in/yaml.v2
           - github.com/alexflint/go-arg
           - github.com/bmatcuk/doublestar/v4
+          - github.com/google/uuid
 
   forbidigo:
     forbid:
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index b15e61f..470451d 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -42,6 +42,8 @@ In addition to several new features and bugfixes, along with this release comes
 
 ### New features:
 
+- genqlient now supports subscriptions; the websocket protocol is by default `graphql-transport-ws` but can be set to another value.  
+  See the [documentation](FAQ.md) for how to `subscribe to an API 'subscription' endpoint`.
 - The new `optional: generic` allows using a generic type to represent optionality. See the [documentation](genqlient.yaml) for details.
 - For schemas with enum values that differ only in casing, it's now possible to disable smart-casing in genqlient.yaml; see the [documentation](genqlient.yaml) for `casing` for details.
 - genqlient now supports .graphqls and .gql file extensions for schemas and queries.
diff --git a/docs/introduction.md b/docs/introduction.md
index f5915d5..a6d1621 100644
--- a/docs/introduction.md
+++ b/docs/introduction.md
@@ -8,7 +8,7 @@ You want the schema in GraphQL [Schema Definition Language (SDL)](https://graphq
 
 ## Step 2: Write your queries
 
-Next, write your GraphQL query.  This is often easiest to do in an interactive explorer like [GraphiQL](https://github.com/graphql/graphiql/tree/main/packages/graphiql#readme); the syntax is just standard [GraphQL syntax](https://graphql.org/learn/queries/) and supports both queries and mutations.  Put it in `genqlient.graphql`:
+Next, write your GraphQL query.  This is often easiest to do in an interactive explorer like [GraphiQL](https://github.com/graphql/graphiql/tree/main/packages/graphiql#readme); the syntax is just standard [GraphQL syntax](https://graphql.org/learn/queries/) and supports queries, mutations and subscriptions.  Put it in `genqlient.graphql`:
 ```graphql
 query getUser($login: String!) {
   user(login: $login) {
diff --git a/docs/subscriptions.md b/docs/subscriptions.md
new file mode 100644
index 0000000..ee4d3d8
--- /dev/null
+++ b/docs/subscriptions.md
@@ -0,0 +1,122 @@
+# Using genqlient with GraphQL subscriptions
+
+This document describes how to use genqlient to make GraphQL subscriptions. It assumes you already have the basic [client](./client_config.md) set up. Subscription support is fairly new; please report any bugs or missing features! 
+
+## Client setup
+
+You will need to use a different client calling `graphql.NewClientUsingWebSocket`, passing as a parameter your own websocket client.
+
+Here is how to configure your webSocket client to match the interfaces:
+
+### Example using `github.com/gorilla/websocket`
+
+```go
+type MyDialer struct {
+	*websocket.Dialer
+}
+
+func (md *MyDialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (graphql.WSConn, error) {
+	conn, _, err := md.Dialer.DialContext(ctx, urlStr, requestHeader)
+	return graphql.WSConn(conn), err
+}
+```
+
+### Example using `golang.org/x/net/websocket`
+
+```go
+type MyDialer struct {
+	dialer *net.Dialer
+}
+
+type MyConn struct {
+	conn *websocket.Conn
+}
+
+func (c MyConn) ReadMessage() (messageType int, p []byte, err error) {
+	if err := websocket.Message.Receive(c.conn, &p); err != nil {
+		return websocket.UnknownFrame, nil, err
+	}
+	return messageType, p, err
+}
+
+func (c MyConn) WriteMessage(_ int, data []byte) error {
+	err := websocket.Message.Send(c.conn, data)
+	return err
+}
+
+func (c MyConn) Close() error {
+	c.conn.Close()
+	return nil
+}
+
+func (md *MyDialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (graphql.WSConn, error) {
+	if md.dialer == nil {
+		return nil, fmt.Errorf("nil dialer")
+	}
+	config, err := websocket.NewConfig(urlStr, "http://localhost")
+	if err != nil {
+		fmt.Println("Error creating WebSocket config:", err)
+		return nil, err
+	}
+	config.Dialer = md.dialer
+	config.Protocol = append(config.Protocol, "graphql-transport-ws")
+
+	// Connect to the WebSocket server
+	conn, err := websocket.DialConfig(config)
+	if err != nil {
+		return nil, err
+	}
+	return graphql.WSConn(MyConn{conn: conn}), err
+}
+```
+
+## Making subscriptions
+
+Once your websocket client matches the interfaces, you can get your `graphql.WebSocketClient` and listen in
+a loop for incoming messages and errors:
+
+```go
+	graphqlClient := graphql.NewClientUsingWebSocket(
+		"ws://localhost:8080/query",
+		&MyDialer{Dialer: dialer},
+		headers,
+	)
+
+	errChan, err := graphqlClient.Start(ctx)
+	if err != nil {
+		return
+	}
+
+	dataChan, subscriptionID, err := count(ctx, graphqlClient)
+	if err != nil {
+		return
+	}
+
+	defer graphqlClient.Close()
+	for loop := true; loop; {
+		select {
+		case msg, more := <-dataChan:
+			if !more {
+				loop = false
+				break
+			}
+			if msg.Data != nil {
+				fmt.Println(msg.Data.Count)
+			}
+			if msg.Errors != nil {
+				fmt.Println("error:", msg.Errors)
+				loop = false
+			}
+		case err = <-errChan:
+			return
+		case <-time.After(time.Minute):
+			err = wsClient.Unsubscribe(subscriptionID)
+			loop = false
+		}
+	}
+```
+
+To change the websocket protocol from its default value `graphql-transport-ws`, add the following header before calling `graphql.NewClientUsingWebSocket()`:
+```go
+	headers.Add("Sec-WebSocket-Protocol", "graphql-ws")
+```
diff --git a/example/generated.go b/example/generated.go
index c13d33b..838e901 100644
--- a/example/generated.go
+++ b/example/generated.go
@@ -69,7 +69,7 @@ func (v *getViewerViewerUser) GetMyName() string { return v.MyName }
 // GetCreatedAt returns getViewerViewerUser.CreatedAt, and is useful for accessing the field via an interface.
 func (v *getViewerViewerUser) GetCreatedAt() time.Time { return v.CreatedAt }
 
-// The query or mutation executed by getUser.
+// The query executed by getUser.
 const getUser_Operation = `
 query getUser ($Login: String!) {
 	user(login: $Login) {
@@ -84,7 +84,7 @@ func getUser(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	Login string,
-) (*getUserResponse, error) {
+) (data_ *getUserResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "getUser",
 		Query:  getUser_Operation,
@@ -92,10 +92,9 @@ func getUser(
 			Login: Login,
 		},
 	}
-	var err_ error
 
-	var data_ getUserResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &getUserResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -103,10 +102,10 @@ func getUser(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by getViewer.
+// The query executed by getViewer.
 const getViewer_Operation = `
 query getViewer {
 	viewer {
@@ -119,15 +118,14 @@ query getViewer {
 func getViewer(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*getViewerResponse, error) {
+) (data_ *getViewerResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "getViewer",
 		Query:  getViewer_Operation,
 	}
-	var err_ error
 
-	var data_ getViewerResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &getViewerResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -135,5 +133,5 @@ func getViewer(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
diff --git a/generate/convert.go b/generate/convert.go
index 44db36d..1a31fd4 100644
--- a/generate/convert.go
+++ b/generate/convert.go
@@ -80,9 +80,6 @@ func (g *generator) baseTypeForOperation(operation ast.Operation) (*ast.Definiti
 	case ast.Mutation:
 		return g.schema.Mutation, nil
 	case ast.Subscription:
-		if !g.Config.AllowBrokenFeatures {
-			return nil, errorf(nil, "genqlient does not yet support subscriptions")
-		}
 		return g.schema.Subscription, nil
 	default:
 		return nil, errorf(nil, "unexpected operation: %v", operation)
diff --git a/generate/generate.go b/generate/generate.go
index cc39c8e..7aeec3d 100644
--- a/generate/generate.go
+++ b/generate/generate.go
@@ -230,7 +230,6 @@ func (g *generator) preprocessQueryDocument(doc *ast.QueryDocument) {
 func (g *generator) validateOperation(op *ast.OperationDefinition) error {
 	_, err := g.baseTypeForOperation(op.Operation)
 	if err != nil {
-		// (e.g. operation has subscriptions, which we don't support)
 		return err
 	}
 
@@ -282,6 +281,9 @@ func (g *generator) addOperation(op *ast.OperationDefinition) error {
 	if commentLines != "" {
 		docComment = "// " + strings.ReplaceAll(commentLines, "\n", "\n// ")
 	}
+	if op.Operation == ast.Subscription {
+		docComment += "\n// To unsubscribe, use [graphql.WebSocketClient.Unsubscribe]"
+	}
 
 	// If the filename is a pseudo-filename filename.go:startline, just
 	// put the filename in the export; we don't figure out the line offset
diff --git a/generate/operation.go.tmpl b/generate/operation.go.tmpl
index a89b83c..1b70890 100644
--- a/generate/operation.go.tmpl
+++ b/generate/operation.go.tmpl
@@ -1,4 +1,4 @@
-// The query or mutation executed by {{.Name}}.
+// The {{.Type}} executed by {{.Name}}.
 const {{.Name}}_Operation = `{{$.Body}}`
 
 {{.Doc}}
@@ -7,7 +7,7 @@ func {{.Name}}(
     ctx_ {{ref .Config.ContextType}},
     {{end}}
     {{- if not .Config.ClientGetter -}}
-    client_ {{ref "github.com/Khan/genqlient/graphql.Client"}},
+    client_ {{if eq .Type "subscription"}}{{ref "github.com/Khan/genqlient/graphql.WebSocketClient"}}{{else}}{{ref "github.com/Khan/genqlient/graphql.Client"}}{{end}},
     {{end}}
     {{- if .Input -}}
     {{- range .Input.Fields -}}
@@ -15,7 +15,7 @@ func {{.Name}}(
     {{.GraphQLName}} {{.GoType.Reference}},
     {{end -}}
     {{end -}}
-) (*{{.ResponseName}}, {{if .Config.Extensions -}}map[string]interface{},{{end}} error) {
+) ({{if eq .Type "subscription"}}dataChan_ chan {{.Name}}WsResponse, subscriptionID_ string,{{else}}data_ *{{.ResponseName}}, {{if .Config.Extensions -}}ext_ map[string]interface{},{{end}}{{end}} err_ error) {
     req_ := &graphql.Request{
         OpName: "{{.Name}}",
         Query:  {{.Name}}_Operation,
@@ -27,7 +27,6 @@ func {{.Name}}(
         },
     {{end -}}
     }
-    var err_ error
     {{if .Config.ClientGetter -}}
     var client_ graphql.Client
 
@@ -36,14 +35,50 @@ func {{.Name}}(
         return nil, {{if .Config.Extensions -}}nil,{{end -}} err_
     }
     {{end}}
-    var data_ {{.ResponseName}}
-    resp_ := &graphql.Response{Data: &data_}
+    {{if eq .Type "subscription"}}
+    dataChan_ = make(chan {{.Name}}WsResponse)
+    subscriptionID_, err_ = client_.Subscribe(req_, dataChan_, {{.Name}}ForwardData)
+    {{else}}
+    data_ = &{{.ResponseName}}{}
+    resp_ := &graphql.Response{Data: data_}
 
     err_ = client_.MakeRequest(
         {{if ne .Config.ContextType "-"}}ctx_{{else}}nil{{end}},
         req_,
         resp_,
     )
+    {{end}}
 	
-    return &data_, {{if .Config.Extensions -}}resp_.Extensions,{{end -}} err_
+    return {{if eq .Type "subscription"}}dataChan_, subscriptionID_,{{else}}data_, {{if .Config.Extensions -}}resp_.Extensions,{{end -}}{{end}} err_
+}
+
+{{if eq .Type "subscription"}}
+type {{.Name}}WsResponse struct {
+	Data       *{{.ResponseName}}     `json:"data"`
+	Extensions map[string]interface{} `json:"extensions,omitempty"`
+	Errors     error                  `json:"errors"`
+}
+
+func {{.Name}}ForwardData(interfaceChan interface{}, jsonRawMsg json.RawMessage) error {
+    var gqlResp graphql.Response
+	var wsResp {{.Name}}WsResponse
+    err := json.Unmarshal(jsonRawMsg, &gqlResp)
+    if err != nil {
+        return err
+    }
+    if len(gqlResp.Errors) == 0 {
+        err = json.Unmarshal(jsonRawMsg, &wsResp)
+        if err != nil {
+            return err
+        }
+    } else {
+        wsResp.Errors = gqlResp.Errors
+    }
+    dataChan_, ok := interfaceChan.(chan {{.Name}}WsResponse)
+	if !ok {
+		return errors.New("failed to cast interface into 'chan {{.Name}}WsResponse'")
+	}
+	dataChan_ <- wsResp
+	return nil
 }
+{{end}}
diff --git a/go.mod b/go.mod
index 2a1f83c..c08045f 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,8 @@ require (
 	github.com/alexflint/go-arg v1.4.2
 	github.com/bmatcuk/doublestar/v4 v4.6.1
 	github.com/bradleyjkemp/cupaloy/v2 v2.6.0
+	github.com/google/uuid v1.6.0
+	github.com/gorilla/websocket v1.5.0
 	github.com/stretchr/testify v1.9.0
 	github.com/vektah/gqlparser/v2 v2.5.16
 	golang.org/x/tools v0.18.0
@@ -17,8 +19,6 @@ require (
 	github.com/agnivade/levenshtein v1.1.1 // indirect
 	github.com/alexflint/go-scalar v1.0.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
-	github.com/google/uuid v1.6.0 // indirect
-	github.com/gorilla/websocket v1.5.0 // indirect
 	github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
 	github.com/mitchellh/mapstructure v1.5.0 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
diff --git a/graphql/client.go b/graphql/client.go
index 469e3c0..526395b 100644
--- a/graphql/client.go
+++ b/graphql/client.go
@@ -40,6 +40,46 @@ type Client interface {
 	) error
 }
 
+type WebSocketClient interface {
+	// Start must open a webSocket connection and subscribe to an endpoint
+	// of the client's GraphQL API.
+	//
+	// errChan is a channel on which are sent the errors of webSocket
+	// communication. It will be closed when calling the `Close()` method.
+	//
+	// err is any error that occurs when setting up the webSocket connection.
+	Start(ctx context.Context) (errChan chan error, err error)
+
+	// Close must close the webSocket connection and close the error channel.
+	// If no connection was started, Close is a no-op
+	Close() error
+
+	// Subscribe must subscribe to an endpoint of the client's GraphQL API.
+	//
+	// req contains the data to be sent to the GraphQL server. Will be marshalled
+	// into JSON bytes.
+	//
+	// interfaceChan is a channel used to send the data that arrives via the
+	// webSocket connection (it is the channel that is passed to `forwardDataFunc`).
+	//
+	// forwardDataFunc is the function that will cast the received interface into
+	// the valid type for the subscription's response.
+	//
+	// Returns a subscriptionID if successful, an error otherwise.
+	Subscribe(
+		req *Request,
+		interfaceChan interface{},
+		forwardDataFunc ForwardDataFunction,
+	) (string, error)
+
+	// Unsubscribe must unsubscribe from an endpoint of the client's GraphQL API.
+	Unsubscribe(subscriptionID string) error
+}
+
+// ForwardDataFunction is a part of the WebSocketClient interface, see
+// [WebSocketClient.Subscribe] for details.
+type ForwardDataFunction func(interfaceChan interface{}, jsonRawMsg json.RawMessage) error
+
 type client struct {
 	httpClient Doer
 	endpoint   string
@@ -53,6 +93,9 @@ type client struct {
 // GraphQL HTTP-over-JSON transport.  It will use the given [http.Client], or
 // [http.DefaultClient] if a nil client is passed.
 //
+// The client does not support subscriptions, and will return an error if passed
+// a request that attempts one.
+//
 // The typical method of adding authentication headers is to wrap the client's
 // [http.Transport] to add those headers.  See [example/main.go] for an
 // example.
@@ -71,8 +114,8 @@ func NewClient(endpoint string, httpClient Doer) Client {
 // parameters.  It will use the given [http.Client], or [http.DefaultClient] if
 // a nil client is passed.
 //
-// The client does not support mutations, and will return an error if passed a
-// request that attempts one.
+// The client does not support mutations nor subscriptions, and will return an
+// error if passed a request that attempts one.
 //
 // The typical method of adding authentication headers is to wrap the client's
 // [http.Transport] to add those headers.  See [example/main.go] for an
@@ -83,6 +126,27 @@ func NewClientUsingGet(endpoint string, httpClient Doer) Client {
 	return newClient(endpoint, httpClient, http.MethodGet)
 }
 
+// NewClientUsingWebSocket returns a [WebSocketClient] which makes subscription requests
+// to the given endpoint using webSocket.
+//
+// The client does not support queries nor mutations, and will return an error
+// if passed a request that attempts one.
+func NewClientUsingWebSocket(endpoint string, wsDialer Dialer, headers http.Header) WebSocketClient {
+	if headers == nil {
+		headers = http.Header{}
+	}
+	if headers.Get("Sec-WebSocket-Protocol") == "" {
+		headers.Add("Sec-WebSocket-Protocol", "graphql-transport-ws")
+	}
+	return &webSocketClient{
+		Dialer:        wsDialer,
+		Header:        headers,
+		errChan:       make(chan error),
+		endpoint:      endpoint,
+		subscriptions: subscriptionMap{map_: make(map[string]subscription)},
+	}
+}
+
 func newClient(endpoint string, httpClient Doer, method string) Client {
 	if httpClient == nil || httpClient == (*http.Client)(nil) {
 		httpClient = http.DefaultClient
@@ -97,6 +161,20 @@ type Doer interface {
 	Do(*http.Request) (*http.Response, error)
 }
 
+// Dialer encapsulates DialContext method and is similar to [github.com/gorilla/websocket]
+// [*websocket.Dialer] method
+type Dialer interface {
+	DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (WSConn, error)
+}
+
+// WSConn encapsulates basic methods for a webSocket connection, taking model on
+// [github.com/gorilla/websocket] [*websocket.Conn]
+type WSConn interface {
+	Close() error
+	WriteMessage(messageType int, data []byte) error
+	ReadMessage() (messageType int, p []byte, err error)
+}
+
 // Request contains all the values required to build queries executed by
 // the [Client].
 //
@@ -178,6 +256,12 @@ func (c *client) MakeRequest(ctx context.Context, req *Request, resp *Response)
 }
 
 func (c *client) createPostRequest(req *Request) (*http.Request, error) {
+	if req.Query != "" {
+		if strings.HasPrefix(strings.TrimSpace(req.Query), "subscription") {
+			return nil, errors.New("client does not support subscriptions")
+		}
+	}
+
 	body, err := json.Marshal(req)
 	if err != nil {
 		return nil, err
@@ -207,6 +291,9 @@ func (c *client) createGetRequest(req *Request) (*http.Request, error) {
 		if strings.HasPrefix(strings.TrimSpace(req.Query), "mutation") {
 			return nil, errors.New("client does not support mutations")
 		}
+		if strings.HasPrefix(strings.TrimSpace(req.Query), "subscription") {
+			return nil, errors.New("client does not support subscriptions")
+		}
 		queryParams.Set("query", req.Query)
 		queryUpdated = true
 	}
diff --git a/graphql/subscription.go b/graphql/subscription.go
new file mode 100644
index 0000000..f86f75e
--- /dev/null
+++ b/graphql/subscription.go
@@ -0,0 +1,66 @@
+package graphql
+
+import (
+	"fmt"
+	"reflect"
+	"sync"
+)
+
+// map of subscription ID to subscription
+type subscriptionMap struct {
+	map_ map[string]subscription
+	sync.RWMutex
+}
+
+type subscription struct {
+	interfaceChan       interface{}
+	forwardDataFunc     ForwardDataFunction
+	id                  string
+	hasBeenUnsubscribed bool
+}
+
+func (s *subscriptionMap) Create(subscriptionID string, interfaceChan interface{}, forwardDataFunc ForwardDataFunction) {
+	s.Lock()
+	defer s.Unlock()
+	s.map_[subscriptionID] = subscription{
+		id:                  subscriptionID,
+		interfaceChan:       interfaceChan,
+		forwardDataFunc:     forwardDataFunc,
+		hasBeenUnsubscribed: false,
+	}
+}
+
+func (s *subscriptionMap) Read(subscriptionID string) (sub subscription, success bool) {
+	s.RLock()
+	defer s.RUnlock()
+	sub, success = s.map_[subscriptionID]
+	return sub, success
+}
+
+func (s *subscriptionMap) Unsubscribe(subscriptionID string) error {
+	s.Lock()
+	defer s.Unlock()
+	unsub, success := s.map_[subscriptionID]
+	if !success {
+		return fmt.Errorf("tried to unsubscribe from unknown subscription with ID '%s'", subscriptionID)
+	}
+	unsub.hasBeenUnsubscribed = true
+	s.map_[subscriptionID] = unsub
+	reflect.ValueOf(s.map_[subscriptionID].interfaceChan).Close()
+	return nil
+}
+
+func (s *subscriptionMap) GetAllIDs() (subscriptionIDs []string) {
+	s.RLock()
+	defer s.RUnlock()
+	for subID := range s.map_ {
+		subscriptionIDs = append(subscriptionIDs, subID)
+	}
+	return subscriptionIDs
+}
+
+func (s *subscriptionMap) Delete(subscriptionID string) {
+	s.Lock()
+	defer s.Unlock()
+	delete(s.map_, subscriptionID)
+}
diff --git a/graphql/websocket.go b/graphql/websocket.go
new file mode 100644
index 0000000..bb9a98b
--- /dev/null
+++ b/graphql/websocket.go
@@ -0,0 +1,261 @@
+package graphql
+
+import (
+	"context"
+	"encoding/binary"
+	"encoding/json"
+	"fmt"
+	"net/http"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/google/uuid"
+)
+
+const (
+	webSocketMethod         = "websocket"
+	webSocketTypeConnInit   = "connection_init"
+	webSocketTypeConnAck    = "connection_ack"
+	webSocketTypeSubscribe  = "subscribe"
+	webSocketTypeNext       = "next"
+	webSocketTypeError      = "error"
+	webSocketTypeComplete   = "complete"
+	websocketConnAckTimeOut = time.Second * 30
+)
+
+// Close codes defined in RFC 6455, section 11.7.
+const (
+	closeNormalClosure    = 1000
+	closeNoStatusReceived = 1005
+)
+
+// The message types are defined in RFC 6455, section 11.8.
+const (
+	// textMessage denotes a text data message. The text message payload is
+	// interpreted as UTF-8 encoded text data.
+	textMessage = 1
+
+	// closeMessage denotes a close control message. The optional message
+	// payload contains a numeric code and text. Use the FormatCloseMessage
+	// function to format a close message payload.
+	closeMessage = 8
+)
+
+type webSocketClient struct {
+	Dialer        Dialer
+	Header        http.Header
+	endpoint      string
+	conn          WSConn
+	errChan       chan error
+	subscriptions subscriptionMap
+	isClosing     bool
+	sync.Mutex
+}
+
+type webSocketSendMessage struct {
+	Payload *Request `json:"payload"`
+	Type    string   `json:"type"`
+	ID      string   `json:"id"`
+}
+
+type webSocketReceiveMessage struct {
+	Type    string          `json:"type"`
+	ID      string          `json:"id"`
+	Payload json.RawMessage `json:"payload"`
+}
+
+func (w *webSocketClient) sendInit() error {
+	connInitMsg := webSocketSendMessage{
+		Type: webSocketTypeConnInit,
+	}
+	return w.sendStructAsJSON(connInitMsg)
+}
+
+func (w *webSocketClient) sendStructAsJSON(object any) error {
+	jsonBytes, err := json.Marshal(object)
+	if err != nil {
+		return err
+	}
+	return w.conn.WriteMessage(textMessage, jsonBytes)
+}
+
+func (w *webSocketClient) waitForConnAck() error {
+	var connAckReceived bool
+	var err error
+	start := time.Now()
+	for !connAckReceived {
+		connAckReceived, err = w.receiveWebSocketConnAck()
+		if err != nil {
+			return err
+		}
+		if time.Since(start) > websocketConnAckTimeOut {
+			return fmt.Errorf("timed out while waiting for connAck (> %v)", websocketConnAckTimeOut)
+		}
+	}
+	return nil
+}
+
+func (w *webSocketClient) handleErr(err error) {
+	w.Lock()
+	defer w.Unlock()
+	if !w.isClosing {
+		w.errChan <- err
+	}
+}
+
+func (w *webSocketClient) listenWebSocket() {
+	for {
+		if w.isClosing {
+			return
+		}
+		_, message, err := w.conn.ReadMessage()
+		if err != nil {
+			w.handleErr(err)
+			return
+		}
+		err = w.forwardWebSocketData(message)
+		if err != nil {
+			w.handleErr(err)
+			return
+		}
+	}
+}
+
+func (w *webSocketClient) forwardWebSocketData(message []byte) error {
+	var wsMsg webSocketReceiveMessage
+	err := json.Unmarshal(message, &wsMsg)
+	if err != nil {
+		return err
+	}
+	sub, ok := w.subscriptions.Read(wsMsg.ID)
+	if !ok {
+		return fmt.Errorf("received message for unknown subscription ID '%s'", wsMsg.ID)
+	}
+	if sub.hasBeenUnsubscribed {
+		return nil
+	}
+	return sub.forwardDataFunc(sub.interfaceChan, wsMsg.Payload)
+}
+
+func (w *webSocketClient) receiveWebSocketConnAck() (bool, error) {
+	_, message, err := w.conn.ReadMessage()
+	if err != nil {
+		return false, err
+	}
+	return checkConnectionAckReceived(message)
+}
+
+func checkConnectionAckReceived(message []byte) (bool, error) {
+	wsMessage := &webSocketSendMessage{}
+	err := json.Unmarshal(message, wsMessage)
+	if err != nil {
+		return false, err
+	}
+	return wsMessage.Type == webSocketTypeConnAck, nil
+}
+
+func (w *webSocketClient) Start(ctx context.Context) (errChan chan error, err error) {
+	w.conn, err = w.Dialer.DialContext(ctx, w.endpoint, w.Header)
+	if err != nil {
+		return nil, err
+	}
+	err = w.sendInit()
+	if err != nil {
+		w.conn.Close()
+		return nil, err
+	}
+	err = w.waitForConnAck()
+	if err != nil {
+		w.conn.Close()
+		return nil, err
+	}
+	go w.listenWebSocket()
+	return w.errChan, err
+}
+
+func (w *webSocketClient) Close() error {
+	if w.conn == nil {
+		return nil
+	}
+	err := w.conn.WriteMessage(closeMessage, formatCloseMessage(closeNormalClosure, ""))
+	if err != nil {
+		return fmt.Errorf("failed to send closure message: %w", err)
+	}
+	err = w.UnsubscribeAll()
+	if err != nil {
+		return fmt.Errorf("failed to unsubscribe: %w", err)
+	}
+	w.Lock()
+	defer w.Unlock()
+	w.isClosing = true
+	close(w.errChan)
+	return w.conn.Close()
+}
+
+func (w *webSocketClient) Subscribe(req *Request, interfaceChan interface{}, forwardDataFunc ForwardDataFunction) (string, error) {
+	if req.Query != "" {
+		if strings.HasPrefix(strings.TrimSpace(req.Query), "query") {
+			return "", fmt.Errorf("client does not support queries")
+		}
+		if strings.HasPrefix(strings.TrimSpace(req.Query), "mutation") {
+			return "", fmt.Errorf("client does not support mutations")
+		}
+	}
+
+	subscriptionID := uuid.NewString()
+	w.subscriptions.Create(subscriptionID, interfaceChan, forwardDataFunc)
+	subscriptionMsg := webSocketSendMessage{
+		Type:    webSocketTypeSubscribe,
+		Payload: req,
+		ID:      subscriptionID,
+	}
+	err := w.sendStructAsJSON(subscriptionMsg)
+	if err != nil {
+		w.subscriptions.Delete(subscriptionID)
+		return "", err
+	}
+	return subscriptionID, nil
+}
+
+func (w *webSocketClient) Unsubscribe(subscriptionID string) error {
+	completeMsg := webSocketSendMessage{
+		Type: webSocketTypeComplete,
+		ID:   subscriptionID,
+	}
+	err := w.sendStructAsJSON(completeMsg)
+	if err != nil {
+		return err
+	}
+	err = w.subscriptions.Unsubscribe(subscriptionID)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (w *webSocketClient) UnsubscribeAll() error {
+	subscriptionIDs := w.subscriptions.GetAllIDs()
+	for _, subscriptionID := range subscriptionIDs {
+		err := w.Unsubscribe(subscriptionID)
+		if err != nil {
+			return err
+		}
+	}
+	return nil
+}
+
+// formatCloseMessage formats closeCode and text as a WebSocket close message.
+// An empty message is returned for code CloseNoStatusReceived.
+func formatCloseMessage(closeCode int, text string) []byte {
+	if closeCode == closeNoStatusReceived {
+		// Return empty message because it's illegal to send
+		// CloseNoStatusReceived. Return non-nil value in case application
+		// checks for nil.
+		return []byte{}
+	}
+	buf := make([]byte, 2+len(text))
+	binary.BigEndian.PutUint16(buf, uint16(closeCode))
+	copy(buf[2:], text)
+	return buf
+}
diff --git a/internal/integration/generated.go b/internal/integration/generated.go
index 2183ce8..9725a7d 100644
--- a/internal/integration/generated.go
+++ b/internal/integration/generated.go
@@ -5,6 +5,7 @@ package integration
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"time"
 
@@ -1305,6 +1306,14 @@ type __queryWithVariablesInput struct {
 // GetId returns __queryWithVariablesInput.Id, and is useful for accessing the field via an interface.
 func (v *__queryWithVariablesInput) GetId() string { return v.Id }
 
+// countResponse is returned by count on success.
+type countResponse struct {
+	Count int `json:"count"`
+}
+
+// GetCount returns countResponse.Count, and is useful for accessing the field via an interface.
+func (v *countResponse) GetCount() int { return v.Count }
+
 // createUserCreateUser includes the requested fields of the GraphQL type User.
 type createUserCreateUser struct {
 	Id   string `json:"id"`
@@ -3082,7 +3091,59 @@ type simpleQueryResponse struct {
 // GetMe returns simpleQueryResponse.Me, and is useful for accessing the field via an interface.
 func (v *simpleQueryResponse) GetMe() simpleQueryMeUser { return v.Me }
 
-// The query or mutation executed by createUser.
+// The subscription executed by count.
+const count_Operation = `
+subscription count {
+	count
+}
+`
+
+// To unsubscribe, use [graphql.WebSocketClient.Unsubscribe]
+func count(
+	ctx_ context.Context,
+	client_ graphql.WebSocketClient,
+) (dataChan_ chan countWsResponse, subscriptionID_ string, err_ error) {
+	req_ := &graphql.Request{
+		OpName: "count",
+		Query:  count_Operation,
+	}
+
+	dataChan_ = make(chan countWsResponse)
+	subscriptionID_, err_ = client_.Subscribe(req_, dataChan_, countForwardData)
+
+	return dataChan_, subscriptionID_, err_
+}
+
+type countWsResponse struct {
+	Data       *countResponse         `json:"data"`
+	Extensions map[string]interface{} `json:"extensions,omitempty"`
+	Errors     error                  `json:"errors"`
+}
+
+func countForwardData(interfaceChan interface{}, jsonRawMsg json.RawMessage) error {
+	var gqlResp graphql.Response
+	var wsResp countWsResponse
+	err := json.Unmarshal(jsonRawMsg, &gqlResp)
+	if err != nil {
+		return err
+	}
+	if len(gqlResp.Errors) == 0 {
+		err = json.Unmarshal(jsonRawMsg, &wsResp)
+		if err != nil {
+			return err
+		}
+	} else {
+		wsResp.Errors = gqlResp.Errors
+	}
+	dataChan_, ok := interfaceChan.(chan countWsResponse)
+	if !ok {
+		return errors.New("failed to cast interface into 'chan countWsResponse'")
+	}
+	dataChan_ <- wsResp
+	return nil
+}
+
+// The mutation executed by createUser.
 const createUser_Operation = `
 mutation createUser ($user: NewUser!) {
 	createUser(input: $user) {
@@ -3096,7 +3157,7 @@ func createUser(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	user NewUser,
-) (*createUserResponse, map[string]interface{}, error) {
+) (data_ *createUserResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "createUser",
 		Query:  createUser_Operation,
@@ -3104,10 +3165,9 @@ func createUser(
 			User: user,
 		},
 	}
-	var err_ error
 
-	var data_ createUserResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &createUserResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3115,10 +3175,10 @@ func createUser(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by failingQuery.
+// The query executed by failingQuery.
 const failingQuery_Operation = `
 query failingQuery {
 	fail
@@ -3131,15 +3191,14 @@ query failingQuery {
 func failingQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*failingQueryResponse, map[string]interface{}, error) {
+) (data_ *failingQueryResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "failingQuery",
 		Query:  failingQuery_Operation,
 	}
-	var err_ error
 
-	var data_ failingQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &failingQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3147,10 +3206,10 @@ func failingQuery(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithCustomMarshal.
+// The query executed by queryWithCustomMarshal.
 const queryWithCustomMarshal_Operation = `
 query queryWithCustomMarshal ($date: Date!) {
 	usersBornOn(date: $date) {
@@ -3165,7 +3224,7 @@ func queryWithCustomMarshal(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	date time.Time,
-) (*queryWithCustomMarshalResponse, map[string]interface{}, error) {
+) (data_ *queryWithCustomMarshalResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithCustomMarshal",
 		Query:  queryWithCustomMarshal_Operation,
@@ -3173,10 +3232,9 @@ func queryWithCustomMarshal(
 			Date: date,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithCustomMarshalResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithCustomMarshalResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3184,10 +3242,10 @@ func queryWithCustomMarshal(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithCustomMarshalOptional.
+// The query executed by queryWithCustomMarshalOptional.
 const queryWithCustomMarshalOptional_Operation = `
 query queryWithCustomMarshalOptional ($date: Date, $id: ID) {
 	userSearch(birthdate: $date, id: $id) {
@@ -3203,7 +3261,7 @@ func queryWithCustomMarshalOptional(
 	client_ graphql.Client,
 	date *time.Time,
 	id *string,
-) (*queryWithCustomMarshalOptionalResponse, map[string]interface{}, error) {
+) (data_ *queryWithCustomMarshalOptionalResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithCustomMarshalOptional",
 		Query:  queryWithCustomMarshalOptional_Operation,
@@ -3212,10 +3270,9 @@ func queryWithCustomMarshalOptional(
 			Id:   id,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithCustomMarshalOptionalResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithCustomMarshalOptionalResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3223,10 +3280,10 @@ func queryWithCustomMarshalOptional(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithCustomMarshalSlice.
+// The query executed by queryWithCustomMarshalSlice.
 const queryWithCustomMarshalSlice_Operation = `
 query queryWithCustomMarshalSlice ($dates: [Date!]!) {
 	usersBornOnDates(dates: $dates) {
@@ -3241,7 +3298,7 @@ func queryWithCustomMarshalSlice(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	dates []time.Time,
-) (*queryWithCustomMarshalSliceResponse, map[string]interface{}, error) {
+) (data_ *queryWithCustomMarshalSliceResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithCustomMarshalSlice",
 		Query:  queryWithCustomMarshalSlice_Operation,
@@ -3249,10 +3306,9 @@ func queryWithCustomMarshalSlice(
 			Dates: dates,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithCustomMarshalSliceResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithCustomMarshalSliceResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3260,10 +3316,10 @@ func queryWithCustomMarshalSlice(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithFlatten.
+// The query executed by queryWithFlatten.
 const queryWithFlatten_Operation = `
 query queryWithFlatten ($ids: [ID!]!) {
 	... QueryFragment
@@ -3312,7 +3368,7 @@ func queryWithFlatten(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	ids []string,
-) (*QueryFragment, map[string]interface{}, error) {
+) (data_ *QueryFragment, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithFlatten",
 		Query:  queryWithFlatten_Operation,
@@ -3320,10 +3376,9 @@ func queryWithFlatten(
 			Ids: ids,
 		},
 	}
-	var err_ error
 
-	var data_ QueryFragment
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryFragment{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3331,10 +3386,10 @@ func queryWithFlatten(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithFragments.
+// The query executed by queryWithFragments.
 const queryWithFragments_Operation = `
 query queryWithFragments ($ids: [ID!]!) {
 	beings(ids: $ids) {
@@ -3377,7 +3432,7 @@ func queryWithFragments(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	ids []string,
-) (*queryWithFragmentsResponse, map[string]interface{}, error) {
+) (data_ *queryWithFragmentsResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithFragments",
 		Query:  queryWithFragments_Operation,
@@ -3385,10 +3440,9 @@ func queryWithFragments(
 			Ids: ids,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithFragmentsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithFragmentsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3396,10 +3450,10 @@ func queryWithFragments(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithInterfaceListField.
+// The query executed by queryWithInterfaceListField.
 const queryWithInterfaceListField_Operation = `
 query queryWithInterfaceListField ($ids: [ID!]!) {
 	beings(ids: $ids) {
@@ -3414,7 +3468,7 @@ func queryWithInterfaceListField(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	ids []string,
-) (*queryWithInterfaceListFieldResponse, map[string]interface{}, error) {
+) (data_ *queryWithInterfaceListFieldResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithInterfaceListField",
 		Query:  queryWithInterfaceListField_Operation,
@@ -3422,10 +3476,9 @@ func queryWithInterfaceListField(
 			Ids: ids,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithInterfaceListFieldResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithInterfaceListFieldResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3433,10 +3486,10 @@ func queryWithInterfaceListField(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithInterfaceListPointerField.
+// The query executed by queryWithInterfaceListPointerField.
 const queryWithInterfaceListPointerField_Operation = `
 query queryWithInterfaceListPointerField ($ids: [ID!]!) {
 	beings(ids: $ids) {
@@ -3451,7 +3504,7 @@ func queryWithInterfaceListPointerField(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	ids []string,
-) (*queryWithInterfaceListPointerFieldResponse, map[string]interface{}, error) {
+) (data_ *queryWithInterfaceListPointerFieldResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithInterfaceListPointerField",
 		Query:  queryWithInterfaceListPointerField_Operation,
@@ -3459,10 +3512,9 @@ func queryWithInterfaceListPointerField(
 			Ids: ids,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithInterfaceListPointerFieldResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithInterfaceListPointerFieldResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3470,10 +3522,10 @@ func queryWithInterfaceListPointerField(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithInterfaceNoFragments.
+// The query executed by queryWithInterfaceNoFragments.
 const queryWithInterfaceNoFragments_Operation = `
 query queryWithInterfaceNoFragments ($id: ID!) {
 	being(id: $id) {
@@ -3492,7 +3544,7 @@ func queryWithInterfaceNoFragments(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	id string,
-) (*queryWithInterfaceNoFragmentsResponse, map[string]interface{}, error) {
+) (data_ *queryWithInterfaceNoFragmentsResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithInterfaceNoFragments",
 		Query:  queryWithInterfaceNoFragments_Operation,
@@ -3500,10 +3552,9 @@ func queryWithInterfaceNoFragments(
 			Id: id,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithInterfaceNoFragmentsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithInterfaceNoFragmentsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3511,10 +3562,10 @@ func queryWithInterfaceNoFragments(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithNamedFragments.
+// The query executed by queryWithNamedFragments.
 const queryWithNamedFragments_Operation = `
 query queryWithNamedFragments ($ids: [ID!]!) {
 	beings(ids: $ids) {
@@ -3557,7 +3608,7 @@ func queryWithNamedFragments(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	ids []string,
-) (*queryWithNamedFragmentsResponse, map[string]interface{}, error) {
+) (data_ *queryWithNamedFragmentsResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithNamedFragments",
 		Query:  queryWithNamedFragments_Operation,
@@ -3565,10 +3616,9 @@ func queryWithNamedFragments(
 			Ids: ids,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithNamedFragmentsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithNamedFragmentsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3576,10 +3626,10 @@ func queryWithNamedFragments(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithOmitempty.
+// The query executed by queryWithOmitempty.
 const queryWithOmitempty_Operation = `
 query queryWithOmitempty ($id: ID) {
 	user(id: $id) {
@@ -3594,7 +3644,7 @@ func queryWithOmitempty(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	id string,
-) (*queryWithOmitemptyResponse, map[string]interface{}, error) {
+) (data_ *queryWithOmitemptyResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithOmitempty",
 		Query:  queryWithOmitempty_Operation,
@@ -3602,10 +3652,9 @@ func queryWithOmitempty(
 			Id: id,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithOmitemptyResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithOmitemptyResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3613,10 +3662,10 @@ func queryWithOmitempty(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by queryWithVariables.
+// The query executed by queryWithVariables.
 const queryWithVariables_Operation = `
 query queryWithVariables ($id: ID!) {
 	user(id: $id) {
@@ -3631,7 +3680,7 @@ func queryWithVariables(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	id string,
-) (*queryWithVariablesResponse, map[string]interface{}, error) {
+) (data_ *queryWithVariablesResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "queryWithVariables",
 		Query:  queryWithVariables_Operation,
@@ -3639,10 +3688,9 @@ func queryWithVariables(
 			Id: id,
 		},
 	}
-	var err_ error
 
-	var data_ queryWithVariablesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &queryWithVariablesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3650,10 +3698,10 @@ func queryWithVariables(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by simpleQuery.
+// The query executed by simpleQuery.
 const simpleQuery_Operation = `
 query simpleQuery {
 	me {
@@ -3668,15 +3716,14 @@ query simpleQuery {
 func simpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*simpleQueryResponse, map[string]interface{}, error) {
+) (data_ *simpleQueryResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "simpleQuery",
 		Query:  simpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ simpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &simpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3684,10 +3731,10 @@ func simpleQuery(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
-// The query or mutation executed by simpleQueryExt.
+// The query executed by simpleQueryExt.
 const simpleQueryExt_Operation = `
 query simpleQueryExt {
 	me {
@@ -3701,15 +3748,14 @@ query simpleQueryExt {
 func simpleQueryExt(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*simpleQueryExtResponse, map[string]interface{}, error) {
+) (data_ *simpleQueryExtResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "simpleQueryExt",
 		Query:  simpleQueryExt_Operation,
 	}
-	var err_ error
 
-	var data_ simpleQueryExtResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &simpleQueryExtResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -3717,5 +3763,5 @@ func simpleQueryExt(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
diff --git a/internal/integration/roundtrip.go b/internal/integration/roundtrip.go
index 1be9996..c9343d5 100644
--- a/internal/integration/roundtrip.go
+++ b/internal/integration/roundtrip.go
@@ -10,9 +10,11 @@ import (
 	"fmt"
 	"io"
 	"net/http"
+	"strings"
 	"testing"
 
 	"github.com/Khan/genqlient/graphql"
+	"github.com/gorilla/websocket"
 	"github.com/stretchr/testify/assert"
 )
 
@@ -46,6 +48,7 @@ func (t *lastResponseTransport) RoundTrip(req *http.Request) (*http.Response, er
 // for each request it processes.
 type roundtripClient struct {
 	wrapped   graphql.Client
+	wsWrapped graphql.WebSocketClient
 	transport *lastResponseTransport
 	t         *testing.T
 }
@@ -103,6 +106,22 @@ func (c *roundtripClient) MakeRequest(ctx context.Context, req *graphql.Request,
 	return nil
 }
 
+func (c *roundtripClient) Start(ctx context.Context) (errChan chan error, err error) {
+	return c.wsWrapped.Start(ctx)
+}
+
+func (c *roundtripClient) Close() error {
+	return c.wsWrapped.Close()
+}
+
+func (c *roundtripClient) Subscribe(req *graphql.Request, interfaceChan interface{}, forwardDataFunc graphql.ForwardDataFunction) (string, error) {
+	return c.wsWrapped.Subscribe(req, interfaceChan, forwardDataFunc)
+}
+
+func (c *roundtripClient) Unsubscribe(subscriptionID string) error {
+	return c.wsWrapped.Unsubscribe(subscriptionID)
+}
+
 func newRoundtripClients(t *testing.T, endpoint string) []graphql.Client {
 	return []graphql.Client{newRoundtripClient(t, endpoint), newRoundtripGetClient(t, endpoint)}
 }
@@ -126,3 +145,25 @@ func newRoundtripGetClient(t *testing.T, endpoint string) graphql.Client {
 		t:         t,
 	}
 }
+
+type MyDialer struct {
+	*websocket.Dialer
+}
+
+func (md *MyDialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (graphql.WSConn, error) {
+	conn, resp, err := md.Dialer.DialContext(ctx, urlStr, requestHeader)
+	resp.Body.Close()
+	return graphql.WSConn(conn), err
+}
+
+func newRoundtripWebScoketClient(t *testing.T, endpoint string) graphql.WebSocketClient {
+	dialer := websocket.DefaultDialer
+	if !strings.HasPrefix(endpoint, "ws") {
+		_, address, _ := strings.Cut(endpoint, "://")
+		endpoint = "ws://" + address
+	}
+	return &roundtripClient{
+		wsWrapped: graphql.NewClientUsingWebSocket(endpoint, &MyDialer{Dialer: dialer}, nil),
+		t:         t,
+	}
+}
diff --git a/internal/integration/schema.graphql b/internal/integration/schema.graphql
index 17e20e2..9f148cc 100644
--- a/internal/integration/schema.graphql
+++ b/internal/integration/schema.graphql
@@ -17,6 +17,10 @@ type Mutation {
   createUser(input: NewUser!): User!
 }
 
+type Subscription {
+  count: Int!
+}
+
 type User implements Being & Lucky {
   id: ID!
   name: String!
diff --git a/internal/integration/server/gqlgen_exec.go b/internal/integration/server/gqlgen_exec.go
index e1dce25..ccf5d2a 100644
--- a/internal/integration/server/gqlgen_exec.go
+++ b/internal/integration/server/gqlgen_exec.go
@@ -7,6 +7,7 @@ import (
 	"context"
 	"errors"
 	"fmt"
+	"io"
 	"strconv"
 	"sync"
 	"sync/atomic"
@@ -37,6 +38,7 @@ type Config struct {
 type ResolverRoot interface {
 	Mutation() MutationResolver
 	Query() QueryResolver
+	Subscription() SubscriptionResolver
 }
 
 type DirectiveRoot struct {
@@ -75,6 +77,10 @@ type ComplexityRoot struct {
 		UsersBornOnDates func(childComplexity int, dates []string) int
 	}
 
+	Subscription struct {
+		Count func(childComplexity int) int
+	}
+
 	User struct {
 		Birthdate   func(childComplexity int) int
 		Friends     func(childComplexity int) int
@@ -100,6 +106,9 @@ type QueryResolver interface {
 	UserSearch(ctx context.Context, birthdate *string, id *string) ([]*User, error)
 	Fail(ctx context.Context) (*bool, error)
 }
+type SubscriptionResolver interface {
+	Count(ctx context.Context) (<-chan int, error)
+}
 
 type executableSchema struct {
 	resolvers  ResolverRoot
@@ -275,6 +284,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
 
 		return e.complexity.Query.UsersBornOnDates(childComplexity, args["dates"].([]string)), true
 
+	case "Subscription.count":
+		if e.complexity.Subscription.Count == nil {
+			break
+		}
+
+		return e.complexity.Subscription.Count(childComplexity), true
+
 	case "User.birthdate":
 		if e.complexity.User.Birthdate == nil {
 			break
@@ -378,6 +394,23 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler {
 			var buf bytes.Buffer
 			data.MarshalGQL(&buf)
 
+			return &graphql.Response{
+				Data: buf.Bytes(),
+			}
+		}
+	case ast.Subscription:
+		next := ec._Subscription(ctx, rc.Operation.SelectionSet)
+
+		var buf bytes.Buffer
+		return func(ctx context.Context) *graphql.Response {
+			buf.Reset()
+			data := next(ctx)
+
+			if data == nil {
+				return nil
+			}
+			data.MarshalGQL(&buf)
+
 			return &graphql.Response{
 				Data: buf.Bytes(),
 			}
@@ -449,6 +482,10 @@ type Mutation {
   createUser(input: NewUser!): User!
 }
 
+type Subscription {
+  count: Int!
+}
+
 type User implements Being & Lucky {
   id: ID!
   name: String!
@@ -1716,6 +1753,64 @@ func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, fie
 	return fc, nil
 }
 
+func (ec *executionContext) _Subscription_count(ctx context.Context, field graphql.CollectedField) (ret func(ctx context.Context) graphql.Marshaler) {
+	fc, err := ec.fieldContext_Subscription_count(ctx, field)
+	if err != nil {
+		return nil
+	}
+	ctx = graphql.WithFieldContext(ctx, fc)
+	defer func() {
+		if r := recover(); r != nil {
+			ec.Error(ctx, ec.Recover(ctx, r))
+			ret = nil
+		}
+	}()
+	resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+		ctx = rctx // use context from middleware stack in children
+		return ec.resolvers.Subscription().Count(rctx)
+	})
+	if err != nil {
+		ec.Error(ctx, err)
+		return nil
+	}
+	if resTmp == nil {
+		if !graphql.HasFieldError(ctx, fc) {
+			ec.Errorf(ctx, "must not be null")
+		}
+		return nil
+	}
+	return func(ctx context.Context) graphql.Marshaler {
+		select {
+		case res, ok := <-resTmp.(<-chan int):
+			if !ok {
+				return nil
+			}
+			return graphql.WriterFunc(func(w io.Writer) {
+				w.Write([]byte{'{'})
+				graphql.MarshalString(field.Alias).MarshalGQL(w)
+				w.Write([]byte{':'})
+				ec.marshalNInt2int(ctx, field.Selections, res).MarshalGQL(w)
+				w.Write([]byte{'}'})
+			})
+		case <-ctx.Done():
+			return nil
+		}
+	}
+}
+
+func (ec *executionContext) fieldContext_Subscription_count(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
+	fc = &graphql.FieldContext{
+		Object:     "Subscription",
+		Field:      field,
+		IsMethod:   true,
+		IsResolver: true,
+		Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
+			return nil, errors.New("field of type Int does not have child fields")
+		},
+	}
+	return fc, nil
+}
+
 func (ec *executionContext) _User_id(ctx context.Context, field graphql.CollectedField, obj *User) (ret graphql.Marshaler) {
 	fc, err := ec.fieldContext_User_id(ctx, field)
 	if err != nil {
@@ -4288,6 +4383,26 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
 	return out
 }
 
+var subscriptionImplementors = []string{"Subscription"}
+
+func (ec *executionContext) _Subscription(ctx context.Context, sel ast.SelectionSet) func(ctx context.Context) graphql.Marshaler {
+	fields := graphql.CollectFields(ec.OperationContext, sel, subscriptionImplementors)
+	ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{
+		Object: "Subscription",
+	})
+	if len(fields) != 1 {
+		ec.Errorf(ctx, "must subscribe to exactly one stream")
+		return nil
+	}
+
+	switch fields[0].Name {
+	case "count":
+		return ec._Subscription_count(ctx, fields[0])
+	default:
+		panic("unknown field " + strconv.Quote(fields[0].Name))
+	}
+}
+
 var userImplementors = []string{"User", "Being", "Lucky"}
 
 func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj *User) graphql.Marshaler {
diff --git a/internal/integration/server/server.go b/internal/integration/server/server.go
index a8a45a7..6526825 100644
--- a/internal/integration/server/server.go
+++ b/internal/integration/server/server.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"net/http/httptest"
 	"strconv"
+	"time"
 
 	"github.com/99designs/gqlgen/graphql"
 	"github.com/99designs/gqlgen/graphql/handler"
@@ -155,10 +156,24 @@ func (m mutationResolver) CreateUser(ctx context.Context, input NewUser) (*User,
 	return &newUser, nil
 }
 
+func (s *subscriptionResolver) Count(ctx context.Context) (<-chan int, error) {
+	respChan := make(chan int, 1)
+	go func(respChan chan int) {
+		counter := 0
+		for {
+			respChan <- counter
+			counter++
+			time.Sleep(time.Second)
+		}
+	}(respChan)
+	return respChan, nil
+}
+
 func RunServer() *httptest.Server {
 	gqlgenServer := handler.New(NewExecutableSchema(Config{Resolvers: &resolver{}}))
 	gqlgenServer.AddTransport(transport.POST{})
 	gqlgenServer.AddTransport(transport.GET{})
+	gqlgenServer.AddTransport(transport.Websocket{})
 	gqlgenServer.AroundResponses(func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
 		graphql.RegisterExtension(ctx, "foobar", "test")
 		return next(ctx)
@@ -167,9 +182,10 @@ func RunServer() *httptest.Server {
 }
 
 type (
-	resolver         struct{}
-	queryResolver    struct{}
-	mutationResolver struct{}
+	resolver             struct{}
+	queryResolver        struct{}
+	mutationResolver     struct{}
+	subscriptionResolver struct{}
 )
 
 func (r *resolver) Mutation() MutationResolver {
@@ -178,4 +194,8 @@ func (r *resolver) Mutation() MutationResolver {
 
 func (r *resolver) Query() QueryResolver { return &queryResolver{} }
 
+func (r *resolver) Subscription() SubscriptionResolver {
+	return &subscriptionResolver{}
+}
+
 //go:generate go run github.com/99designs/gqlgen@v0.17.35


Test patch:
diff --git a/generate/testdata/queries/SimpleSubscription.graphql b/generate/testdata/queries/SimpleSubscription.graphql
new file mode 100644
index 0000000..169bbc0
--- /dev/null
+++ b/generate/testdata/queries/SimpleSubscription.graphql
@@ -0,0 +1,1 @@
+subscription SimpleSubscription { count }
\ No newline at end of file
diff --git a/generate/testdata/queries/schema.graphql b/generate/testdata/queries/schema.graphql
index 528b21e..e1fe9aa 100644
--- a/generate/testdata/queries/schema.graphql
+++ b/generate/testdata/queries/schema.graphql
@@ -218,6 +218,10 @@ input IntComparisonExp {
   _nin: [Int!]
 }
 
+type Subscription {
+  count: Int!
+}
+
 input InputWithDefaults {
   field: String! = "input field omitted"
   nullableField: String = "nullable input field omitted"
diff --git a/generate/testdata/snapshots/TestGenerate-ComplexInlineFragments.graphql-ComplexInlineFragments.graphql.go b/generate/testdata/snapshots/TestGenerate-ComplexInlineFragments.graphql-ComplexInlineFragments.graphql.go
index d5591c0..2a3fb16 100644
--- a/generate/testdata/snapshots/TestGenerate-ComplexInlineFragments.graphql-ComplexInlineFragments.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-ComplexInlineFragments.graphql-ComplexInlineFragments.graphql.go
@@ -1340,7 +1340,7 @@ func (v *ComplexInlineFragmentsRootTopic) GetSchoolGrade() string { return v.Sch
 // GetName returns ComplexInlineFragmentsRootTopic.Name, and is useful for accessing the field via an interface.
 func (v *ComplexInlineFragmentsRootTopic) GetName() string { return v.Name }
 
-// The query or mutation executed by ComplexInlineFragments.
+// The query executed by ComplexInlineFragments.
 const ComplexInlineFragments_Operation = `
 query ComplexInlineFragments {
 	root {
@@ -1436,15 +1436,14 @@ query ComplexInlineFragments {
 // interfaces yet.
 func ComplexInlineFragments(
 	client_ graphql.Client,
-) (*ComplexInlineFragmentsResponse, error) {
+) (data_ *ComplexInlineFragmentsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ComplexInlineFragments",
 		Query:  ComplexInlineFragments_Operation,
 	}
-	var err_ error
 
-	var data_ ComplexInlineFragmentsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ComplexInlineFragmentsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -1452,6 +1451,6 @@ func ComplexInlineFragments(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-ComplexNamedFragments.graphql-ComplexNamedFragments.graphql.go b/generate/testdata/snapshots/TestGenerate-ComplexNamedFragments.graphql-ComplexNamedFragments.graphql.go
index b7fa016..1ea1a5a 100644
--- a/generate/testdata/snapshots/TestGenerate-ComplexNamedFragments.graphql-ComplexNamedFragments.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-ComplexNamedFragments.graphql-ComplexNamedFragments.graphql.go
@@ -2538,7 +2538,7 @@ type VideoFieldsThumbnail struct {
 // GetId returns VideoFieldsThumbnail.Id, and is useful for accessing the field via an interface.
 func (v *VideoFieldsThumbnail) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by ComplexNamedFragments.
+// The query executed by ComplexNamedFragments.
 const ComplexNamedFragments_Operation = `
 query ComplexNamedFragments {
 	... on Query {
@@ -2601,15 +2601,14 @@ fragment MoreVideoFields on Video {
 
 func ComplexNamedFragments(
 	client_ graphql.Client,
-) (*ComplexNamedFragmentsResponse, error) {
+) (data_ *ComplexNamedFragmentsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ComplexNamedFragments",
 		Query:  ComplexNamedFragments_Operation,
 	}
-	var err_ error
 
-	var data_ ComplexNamedFragmentsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ComplexNamedFragmentsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -2617,10 +2616,10 @@ func ComplexNamedFragments(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by ComplexNamedFragmentsWithInlineUnion.
+// The query executed by ComplexNamedFragmentsWithInlineUnion.
 const ComplexNamedFragmentsWithInlineUnion_Operation = `
 query ComplexNamedFragmentsWithInlineUnion {
 	user {
@@ -2654,15 +2653,14 @@ fragment SimpleLeafContent on LeafContent {
 
 func ComplexNamedFragmentsWithInlineUnion(
 	client_ graphql.Client,
-) (*ComplexNamedFragmentsWithInlineUnionResponse, error) {
+) (data_ *ComplexNamedFragmentsWithInlineUnionResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ComplexNamedFragmentsWithInlineUnion",
 		Query:  ComplexNamedFragmentsWithInlineUnion_Operation,
 	}
-	var err_ error
 
-	var data_ ComplexNamedFragmentsWithInlineUnionResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ComplexNamedFragmentsWithInlineUnionResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -2670,6 +2668,6 @@ func ComplexNamedFragmentsWithInlineUnion(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-CovariantInterfaceImplementation.graphql-CovariantInterfaceImplementation.graphql.go b/generate/testdata/snapshots/TestGenerate-CovariantInterfaceImplementation.graphql-CovariantInterfaceImplementation.graphql.go
index 74aa577..251b9b0 100644
--- a/generate/testdata/snapshots/TestGenerate-CovariantInterfaceImplementation.graphql-CovariantInterfaceImplementation.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-CovariantInterfaceImplementation.graphql-CovariantInterfaceImplementation.graphql.go
@@ -2346,7 +2346,7 @@ type TopicFieldsRelatedTopic struct {
 // GetId returns TopicFieldsRelatedTopic.Id, and is useful for accessing the field via an interface.
 func (v *TopicFieldsRelatedTopic) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by CovariantInterfaceImplementation.
+// The query executed by CovariantInterfaceImplementation.
 const CovariantInterfaceImplementation_Operation = `
 query CovariantInterfaceImplementation {
 	randomItem {
@@ -2394,15 +2394,14 @@ fragment TopicFields on Topic {
 
 func CovariantInterfaceImplementation(
 	client_ graphql.Client,
-) (*CovariantInterfaceImplementationResponse, error) {
+) (data_ *CovariantInterfaceImplementationResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "CovariantInterfaceImplementation",
 		Query:  CovariantInterfaceImplementation_Operation,
 	}
-	var err_ error
 
-	var data_ CovariantInterfaceImplementationResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &CovariantInterfaceImplementationResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -2410,6 +2409,6 @@ func CovariantInterfaceImplementation(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-CustomMarshal.graphql-CustomMarshal.graphql.go b/generate/testdata/snapshots/TestGenerate-CustomMarshal.graphql-CustomMarshal.graphql.go
index 7f67c02..1d349a8 100644
--- a/generate/testdata/snapshots/TestGenerate-CustomMarshal.graphql-CustomMarshal.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-CustomMarshal.graphql-CustomMarshal.graphql.go
@@ -174,7 +174,7 @@ func (v *__CustomMarshalInput) __premarshalJSON() (*__premarshal__CustomMarshalI
 	return &retval, nil
 }
 
-// The query or mutation executed by CustomMarshal.
+// The query executed by CustomMarshal.
 const CustomMarshal_Operation = `
 query CustomMarshal ($date: Date!) {
 	usersBornOn(date: $date) {
@@ -187,7 +187,7 @@ query CustomMarshal ($date: Date!) {
 func CustomMarshal(
 	client_ graphql.Client,
 	date time.Time,
-) (*CustomMarshalResponse, error) {
+) (data_ *CustomMarshalResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "CustomMarshal",
 		Query:  CustomMarshal_Operation,
@@ -195,10 +195,9 @@ func CustomMarshal(
 			Date: date,
 		},
 	}
-	var err_ error
 
-	var data_ CustomMarshalResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &CustomMarshalResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -206,6 +205,6 @@ func CustomMarshal(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-CustomMarshalSlice.graphql-CustomMarshalSlice.graphql.go b/generate/testdata/snapshots/TestGenerate-CustomMarshalSlice.graphql-CustomMarshalSlice.graphql.go
index 0ed6bec..a18dcb2 100644
--- a/generate/testdata/snapshots/TestGenerate-CustomMarshalSlice.graphql-CustomMarshalSlice.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-CustomMarshalSlice.graphql-CustomMarshalSlice.graphql.go
@@ -203,7 +203,7 @@ func (v *__CustomMarshalSliceInput) __premarshalJSON() (*__premarshal__CustomMar
 	return &retval, nil
 }
 
-// The query or mutation executed by CustomMarshalSlice.
+// The query executed by CustomMarshalSlice.
 const CustomMarshalSlice_Operation = `
 query CustomMarshalSlice ($datesss: [[[Date!]!]!]!, $datesssp: [[[Date!]!]!]!) {
 	acceptsListOfListOfListsOfDates(datesss: $datesss)
@@ -215,7 +215,7 @@ func CustomMarshalSlice(
 	client_ graphql.Client,
 	datesss [][][]time.Time,
 	datesssp [][][]*time.Time,
-) (*CustomMarshalSliceResponse, error) {
+) (data_ *CustomMarshalSliceResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "CustomMarshalSlice",
 		Query:  CustomMarshalSlice_Operation,
@@ -224,10 +224,9 @@ func CustomMarshalSlice(
 			Datesssp: datesssp,
 		},
 	}
-	var err_ error
 
-	var data_ CustomMarshalSliceResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &CustomMarshalSliceResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -235,6 +234,6 @@ func CustomMarshalSlice(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-DateTime.graphql-DateTime.graphql.go b/generate/testdata/snapshots/TestGenerate-DateTime.graphql-DateTime.graphql.go
index 3bf2390..fdfadf8 100644
--- a/generate/testdata/snapshots/TestGenerate-DateTime.graphql-DateTime.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-DateTime.graphql-DateTime.graphql.go
@@ -28,7 +28,7 @@ type convertTimezoneResponse struct {
 // GetConvert returns convertTimezoneResponse.Convert, and is useful for accessing the field via an interface.
 func (v *convertTimezoneResponse) GetConvert() time.Time { return v.Convert }
 
-// The query or mutation executed by convertTimezone.
+// The query executed by convertTimezone.
 const convertTimezone_Operation = `
 query convertTimezone ($dt: DateTime!, $tz: String) {
 	convert(dt: $dt, tz: $tz)
@@ -39,7 +39,7 @@ func convertTimezone(
 	client_ graphql.Client,
 	dt time.Time,
 	tz string,
-) (*convertTimezoneResponse, error) {
+) (data_ *convertTimezoneResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "convertTimezone",
 		Query:  convertTimezone_Operation,
@@ -48,10 +48,9 @@ func convertTimezone(
 			Tz: tz,
 		},
 	}
-	var err_ error
 
-	var data_ convertTimezoneResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &convertTimezoneResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -59,6 +58,6 @@ func convertTimezone(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.go b/generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.go
index b397193..404fcd5 100644
--- a/generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-DefaultInputs.graphql-DefaultInputs.graphql.go
@@ -33,7 +33,7 @@ type __DefaultInputsInput struct {
 // GetInput returns __DefaultInputsInput.Input, and is useful for accessing the field via an interface.
 func (v *__DefaultInputsInput) GetInput() InputWithDefaults { return v.Input }
 
-// The query or mutation executed by DefaultInputs.
+// The query executed by DefaultInputs.
 const DefaultInputs_Operation = `
 query DefaultInputs ($input: InputWithDefaults!) {
 	default(input: $input)
@@ -45,7 +45,7 @@ query DefaultInputs ($input: InputWithDefaults!) {
 func DefaultInputs(
 	client_ graphql.Client,
 	input InputWithDefaults,
-) (*DefaultInputsResponse, error) {
+) (data_ *DefaultInputsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "DefaultInputs",
 		Query:  DefaultInputs_Operation,
@@ -53,10 +53,9 @@ func DefaultInputs(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ DefaultInputsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &DefaultInputsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -64,6 +63,6 @@ func DefaultInputs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.go b/generate/testdata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.go
index a279302..4617210 100644
--- a/generate/testdata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-DefaultInputsPointer.graphql-DefaultInputsPointer.graphql.go
@@ -33,7 +33,7 @@ type __DefaultInputsInput struct {
 // GetInput returns __DefaultInputsInput.Input, and is useful for accessing the field via an interface.
 func (v *__DefaultInputsInput) GetInput() InputWithDefaults { return v.Input }
 
-// The query or mutation executed by DefaultInputs.
+// The query executed by DefaultInputs.
 const DefaultInputs_Operation = `
 query DefaultInputs ($input: InputWithDefaults!) {
 	default(input: $input)
@@ -46,7 +46,7 @@ query DefaultInputs ($input: InputWithDefaults!) {
 func DefaultInputs(
 	client_ graphql.Client,
 	input InputWithDefaults,
-) (*DefaultInputsResponse, error) {
+) (data_ *DefaultInputsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "DefaultInputs",
 		Query:  DefaultInputs_Operation,
@@ -54,10 +54,9 @@ func DefaultInputs(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ DefaultInputsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &DefaultInputsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -65,6 +64,6 @@ func DefaultInputs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-DefaultInputsWithDirective.graphql-DefaultInputsWithDirective.graphql.go b/generate/testdata/snapshots/TestGenerate-DefaultInputsWithDirective.graphql-DefaultInputsWithDirective.graphql.go
index 51aee5c..8ca4cad 100644
--- a/generate/testdata/snapshots/TestGenerate-DefaultInputsWithDirective.graphql-DefaultInputsWithDirective.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-DefaultInputsWithDirective.graphql-DefaultInputsWithDirective.graphql.go
@@ -33,7 +33,7 @@ type __DefaultInputsInput struct {
 // GetInput returns __DefaultInputsInput.Input, and is useful for accessing the field via an interface.
 func (v *__DefaultInputsInput) GetInput() InputWithDefaults { return v.Input }
 
-// The query or mutation executed by DefaultInputs.
+// The query executed by DefaultInputs.
 const DefaultInputs_Operation = `
 query DefaultInputs ($input: InputWithDefaults!) {
 	default(input: $input)
@@ -44,7 +44,7 @@ query DefaultInputs ($input: InputWithDefaults!) {
 func DefaultInputs(
 	client_ graphql.Client,
 	input InputWithDefaults,
-) (*DefaultInputsResponse, error) {
+) (data_ *DefaultInputsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "DefaultInputs",
 		Query:  DefaultInputs_Operation,
@@ -52,10 +52,9 @@ func DefaultInputs(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ DefaultInputsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &DefaultInputsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -63,6 +62,6 @@ func DefaultInputs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-DefaultInputsWithForDirective.graphql-DefaultInputsWithForDirective.graphql.go b/generate/testdata/snapshots/TestGenerate-DefaultInputsWithForDirective.graphql-DefaultInputsWithForDirective.graphql.go
index 5c76a56..0aa8066 100644
--- a/generate/testdata/snapshots/TestGenerate-DefaultInputsWithForDirective.graphql-DefaultInputsWithForDirective.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-DefaultInputsWithForDirective.graphql-DefaultInputsWithForDirective.graphql.go
@@ -33,7 +33,7 @@ type __DefaultInputsInput struct {
 // GetInput returns __DefaultInputsInput.Input, and is useful for accessing the field via an interface.
 func (v *__DefaultInputsInput) GetInput() InputWithDefaults { return v.Input }
 
-// The query or mutation executed by DefaultInputs.
+// The query executed by DefaultInputs.
 const DefaultInputs_Operation = `
 query DefaultInputs ($input: InputWithDefaults!) {
 	default(input: $input)
@@ -43,7 +43,7 @@ query DefaultInputs ($input: InputWithDefaults!) {
 func DefaultInputs(
 	client_ graphql.Client,
 	input InputWithDefaults,
-) (*DefaultInputsResponse, error) {
+) (data_ *DefaultInputsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "DefaultInputs",
 		Query:  DefaultInputs_Operation,
@@ -51,10 +51,9 @@ func DefaultInputs(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ DefaultInputsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &DefaultInputsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -62,6 +61,6 @@ func DefaultInputs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-EmptyInterface.graphql-EmptyInterface.graphql.go b/generate/testdata/snapshots/TestGenerate-EmptyInterface.graphql-EmptyInterface.graphql.go
index 95d902d..e78dd9d 100644
--- a/generate/testdata/snapshots/TestGenerate-EmptyInterface.graphql-EmptyInterface.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-EmptyInterface.graphql-EmptyInterface.graphql.go
@@ -20,7 +20,7 @@ func (v *EmptyInterfaceResponse) GetGetComplexJunk() []map[string]*[]*map[string
 	return v.GetComplexJunk
 }
 
-// The query or mutation executed by EmptyInterface.
+// The query executed by EmptyInterface.
 const EmptyInterface_Operation = `
 query EmptyInterface {
 	getJunk
@@ -30,15 +30,14 @@ query EmptyInterface {
 
 func EmptyInterface(
 	client_ graphql.Client,
-) (*EmptyInterfaceResponse, error) {
+) (data_ *EmptyInterfaceResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "EmptyInterface",
 		Query:  EmptyInterface_Operation,
 	}
-	var err_ error
 
-	var data_ EmptyInterfaceResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &EmptyInterfaceResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -46,6 +45,6 @@ func EmptyInterface(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Flatten.graphql-Flatten.graphql.go b/generate/testdata/snapshots/TestGenerate-Flatten.graphql-Flatten.graphql.go
index 76499bc..6460abf 100644
--- a/generate/testdata/snapshots/TestGenerate-Flatten.graphql-Flatten.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Flatten.graphql-Flatten.graphql.go
@@ -266,7 +266,7 @@ type VideoFieldsParentTopic struct {
 // GetVideoChildren returns VideoFieldsParentTopic.VideoChildren, and is useful for accessing the field via an interface.
 func (v *VideoFieldsParentTopic) GetVideoChildren() []ChildVideoFields { return v.VideoChildren }
 
-// The query or mutation executed by ComplexNamedFragments.
+// The query executed by ComplexNamedFragments.
 const ComplexNamedFragments_Operation = `
 query ComplexNamedFragments {
 	... QueryFragment
@@ -306,15 +306,14 @@ fragment ChildVideoFields on Video {
 
 func ComplexNamedFragments(
 	client_ graphql.Client,
-) (*InnerQueryFragment, error) {
+) (data_ *InnerQueryFragment, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ComplexNamedFragments",
 		Query:  ComplexNamedFragments_Operation,
 	}
-	var err_ error
 
-	var data_ InnerQueryFragment
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InnerQueryFragment{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -322,6 +321,6 @@ func ComplexNamedFragments(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.go b/generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.go
index d1dc426..27e36c6 100644
--- a/generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Hasura.graphql-Hasura.graphql.go
@@ -81,7 +81,7 @@ type __GetPokemonInput struct {
 // GetWhere returns __GetPokemonInput.Where, and is useful for accessing the field via an interface.
 func (v *__GetPokemonInput) GetWhere() *GetPokemonBoolExp { return v.Where }
 
-// The query or mutation executed by GetPokemon.
+// The query executed by GetPokemon.
 const GetPokemon_Operation = `
 query GetPokemon ($where: getPokemonBoolExp!) {
 	getPokemon(where: $where) {
@@ -94,7 +94,7 @@ query GetPokemon ($where: getPokemonBoolExp!) {
 func GetPokemon(
 	client_ graphql.Client,
 	where *GetPokemonBoolExp,
-) (*GetPokemonResponse, error) {
+) (data_ *GetPokemonResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "GetPokemon",
 		Query:  GetPokemon_Operation,
@@ -102,10 +102,9 @@ func GetPokemon(
 			Where: where,
 		},
 	}
-	var err_ error
 
-	var data_ GetPokemonResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &GetPokemonResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -113,6 +112,6 @@ func GetPokemon(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InputEnum.graphql-InputEnum.graphql.go b/generate/testdata/snapshots/TestGenerate-InputEnum.graphql-InputEnum.graphql.go
index 49e46c3..8abae86 100644
--- a/generate/testdata/snapshots/TestGenerate-InputEnum.graphql-InputEnum.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InputEnum.graphql-InputEnum.graphql.go
@@ -54,7 +54,7 @@ type __InputEnumQueryInput struct {
 // GetRole returns __InputEnumQueryInput.Role, and is useful for accessing the field via an interface.
 func (v *__InputEnumQueryInput) GetRole() Role { return v.Role }
 
-// The query or mutation executed by InputEnumQuery.
+// The query executed by InputEnumQuery.
 const InputEnumQuery_Operation = `
 query InputEnumQuery ($role: Role!) {
 	usersWithRole(role: $role) {
@@ -66,7 +66,7 @@ query InputEnumQuery ($role: Role!) {
 func InputEnumQuery(
 	client_ graphql.Client,
 	role Role,
-) (*InputEnumQueryResponse, error) {
+) (data_ *InputEnumQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InputEnumQuery",
 		Query:  InputEnumQuery_Operation,
@@ -74,10 +74,9 @@ func InputEnumQuery(
 			Role: role,
 		},
 	}
-	var err_ error
 
-	var data_ InputEnumQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InputEnumQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -85,6 +84,6 @@ func InputEnumQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InputObject.graphql-InputObject.graphql.go b/generate/testdata/snapshots/TestGenerate-InputObject.graphql-InputObject.graphql.go
index 9209e04..bcf810c 100644
--- a/generate/testdata/snapshots/TestGenerate-InputObject.graphql-InputObject.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InputObject.graphql-InputObject.graphql.go
@@ -177,7 +177,7 @@ type __InputObjectQueryInput struct {
 // GetQuery returns __InputObjectQueryInput.Query, and is useful for accessing the field via an interface.
 func (v *__InputObjectQueryInput) GetQuery() UserQueryInput { return v.Query }
 
-// The query or mutation executed by InputObjectQuery.
+// The query executed by InputObjectQuery.
 const InputObjectQuery_Operation = `
 query InputObjectQuery ($query: UserQueryInput) {
 	user(query: $query) {
@@ -189,7 +189,7 @@ query InputObjectQuery ($query: UserQueryInput) {
 func InputObjectQuery(
 	client_ graphql.Client,
 	query UserQueryInput,
-) (*InputObjectQueryResponse, error) {
+) (data_ *InputObjectQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InputObjectQuery",
 		Query:  InputObjectQuery_Operation,
@@ -197,10 +197,9 @@ func InputObjectQuery(
 			Query: query,
 		},
 	}
-	var err_ error
 
-	var data_ InputObjectQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InputObjectQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -208,6 +207,6 @@ func InputObjectQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InterfaceListField.graphql-InterfaceListField.graphql.go b/generate/testdata/snapshots/TestGenerate-InterfaceListField.graphql-InterfaceListField.graphql.go
index c5dcb07..19f6ff5 100644
--- a/generate/testdata/snapshots/TestGenerate-InterfaceListField.graphql-InterfaceListField.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InterfaceListField.graphql-InterfaceListField.graphql.go
@@ -520,7 +520,7 @@ func (v *InterfaceListFieldWithPointerTopicChildrenVideo) GetId() testutil.ID {
 // GetName returns InterfaceListFieldWithPointerTopicChildrenVideo.Name, and is useful for accessing the field via an interface.
 func (v *InterfaceListFieldWithPointerTopicChildrenVideo) GetName() string { return v.Name }
 
-// The query or mutation executed by InterfaceListField.
+// The query executed by InterfaceListField.
 const InterfaceListField_Operation = `
 query InterfaceListField {
 	root {
@@ -546,15 +546,14 @@ query InterfaceListField {
 
 func InterfaceListField(
 	client_ graphql.Client,
-) (*InterfaceListFieldResponse, error) {
+) (data_ *InterfaceListFieldResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InterfaceListField",
 		Query:  InterfaceListField_Operation,
 	}
-	var err_ error
 
-	var data_ InterfaceListFieldResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InterfaceListFieldResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -562,6 +561,6 @@ func InterfaceListField(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InterfaceListOfListsOfListsField.graphql-InterfaceListOfListsOfListsField.graphql.go b/generate/testdata/snapshots/TestGenerate-InterfaceListOfListsOfListsField.graphql-InterfaceListOfListsOfListsField.graphql.go
index 2d13e43..204bae3 100644
--- a/generate/testdata/snapshots/TestGenerate-InterfaceListOfListsOfListsField.graphql-InterfaceListOfListsOfListsField.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InterfaceListOfListsOfListsField.graphql-InterfaceListOfListsOfListsField.graphql.go
@@ -506,7 +506,7 @@ func (v *InterfaceListOfListOfListsFieldWithPointerVideo) GetId() *testutil.ID {
 // GetName returns InterfaceListOfListOfListsFieldWithPointerVideo.Name, and is useful for accessing the field via an interface.
 func (v *InterfaceListOfListOfListsFieldWithPointerVideo) GetName() *string { return v.Name }
 
-// The query or mutation executed by InterfaceListOfListOfListsField.
+// The query executed by InterfaceListOfListOfListsField.
 const InterfaceListOfListOfListsField_Operation = `
 query InterfaceListOfListOfListsField {
 	listOfListsOfListsOfContent {
@@ -524,15 +524,14 @@ query InterfaceListOfListOfListsField {
 
 func InterfaceListOfListOfListsField(
 	client_ graphql.Client,
-) (*InterfaceListOfListOfListsFieldResponse, error) {
+) (data_ *InterfaceListOfListOfListsFieldResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InterfaceListOfListOfListsField",
 		Query:  InterfaceListOfListOfListsField_Operation,
 	}
-	var err_ error
 
-	var data_ InterfaceListOfListOfListsFieldResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InterfaceListOfListOfListsFieldResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -540,6 +539,6 @@ func InterfaceListOfListOfListsField(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InterfaceNesting.graphql-InterfaceNesting.graphql.go b/generate/testdata/snapshots/TestGenerate-InterfaceNesting.graphql-InterfaceNesting.graphql.go
index 5f87208..b3dc63b 100644
--- a/generate/testdata/snapshots/TestGenerate-InterfaceNesting.graphql-InterfaceNesting.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InterfaceNesting.graphql-InterfaceNesting.graphql.go
@@ -504,7 +504,7 @@ func (v *InterfaceNestingRootTopicChildrenVideo) GetParent() InterfaceNestingRoo
 	return v.Parent
 }
 
-// The query or mutation executed by InterfaceNesting.
+// The query executed by InterfaceNesting.
 const InterfaceNesting_Operation = `
 query InterfaceNesting {
 	root {
@@ -526,15 +526,14 @@ query InterfaceNesting {
 
 func InterfaceNesting(
 	client_ graphql.Client,
-) (*InterfaceNestingResponse, error) {
+) (data_ *InterfaceNestingResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InterfaceNesting",
 		Query:  InterfaceNesting_Operation,
 	}
-	var err_ error
 
-	var data_ InterfaceNestingResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InterfaceNestingResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -542,6 +541,6 @@ func InterfaceNesting(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-InterfaceNoFragments.graphql-InterfaceNoFragments.graphql.go b/generate/testdata/snapshots/TestGenerate-InterfaceNoFragments.graphql-InterfaceNoFragments.graphql.go
index bd4c7f0..f77e3e5 100644
--- a/generate/testdata/snapshots/TestGenerate-InterfaceNoFragments.graphql-InterfaceNoFragments.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-InterfaceNoFragments.graphql-InterfaceNoFragments.graphql.go
@@ -626,7 +626,7 @@ func (v *InterfaceNoFragmentsQueryWithPointerVideo) GetId() *testutil.ID { retur
 // GetName returns InterfaceNoFragmentsQueryWithPointerVideo.Name, and is useful for accessing the field via an interface.
 func (v *InterfaceNoFragmentsQueryWithPointerVideo) GetName() *string { return v.Name }
 
-// The query or mutation executed by InterfaceNoFragmentsQuery.
+// The query executed by InterfaceNoFragmentsQuery.
 const InterfaceNoFragmentsQuery_Operation = `
 query InterfaceNoFragmentsQuery {
 	root {
@@ -653,15 +653,14 @@ query InterfaceNoFragmentsQuery {
 
 func InterfaceNoFragmentsQuery(
 	client_ graphql.Client,
-) (*InterfaceNoFragmentsQueryResponse, error) {
+) (data_ *InterfaceNoFragmentsQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InterfaceNoFragmentsQuery",
 		Query:  InterfaceNoFragmentsQuery_Operation,
 	}
-	var err_ error
 
-	var data_ InterfaceNoFragmentsQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InterfaceNoFragmentsQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -669,6 +668,6 @@ func InterfaceNoFragmentsQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-ListInput.graphql-ListInput.graphql.go b/generate/testdata/snapshots/TestGenerate-ListInput.graphql-ListInput.graphql.go
index 2d3dfc1..5076d7e 100644
--- a/generate/testdata/snapshots/TestGenerate-ListInput.graphql-ListInput.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-ListInput.graphql-ListInput.graphql.go
@@ -41,7 +41,7 @@ type __ListInputQueryInput struct {
 // GetNames returns __ListInputQueryInput.Names, and is useful for accessing the field via an interface.
 func (v *__ListInputQueryInput) GetNames() []string { return v.Names }
 
-// The query or mutation executed by ListInputQuery.
+// The query executed by ListInputQuery.
 const ListInputQuery_Operation = `
 query ListInputQuery ($names: [String]) {
 	user(query: {names:$names}) {
@@ -53,7 +53,7 @@ query ListInputQuery ($names: [String]) {
 func ListInputQuery(
 	client_ graphql.Client,
 	names []string,
-) (*ListInputQueryResponse, error) {
+) (data_ *ListInputQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ListInputQuery",
 		Query:  ListInputQuery_Operation,
@@ -61,10 +61,9 @@ func ListInputQuery(
 			Names: names,
 		},
 	}
-	var err_ error
 
-	var data_ ListInputQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ListInputQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -72,6 +71,6 @@ func ListInputQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-ListOfListsOfLists.graphql-ListOfListsOfLists.graphql.go b/generate/testdata/snapshots/TestGenerate-ListOfListsOfLists.graphql-ListOfListsOfLists.graphql.go
index e536cf6..7405509 100644
--- a/generate/testdata/snapshots/TestGenerate-ListOfListsOfLists.graphql-ListOfListsOfLists.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-ListOfListsOfLists.graphql-ListOfListsOfLists.graphql.go
@@ -16,7 +16,7 @@ func (v *ListOfListsOfListsResponse) GetListOfListsOfLists() [][][]string {
 	return v.ListOfListsOfLists
 }
 
-// The query or mutation executed by ListOfListsOfLists.
+// The query executed by ListOfListsOfLists.
 const ListOfListsOfLists_Operation = `
 query ListOfListsOfLists {
 	listOfListsOfLists
@@ -25,15 +25,14 @@ query ListOfListsOfLists {
 
 func ListOfListsOfLists(
 	client_ graphql.Client,
-) (*ListOfListsOfListsResponse, error) {
+) (data_ *ListOfListsOfListsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ListOfListsOfLists",
 		Query:  ListOfListsOfLists_Operation,
 	}
-	var err_ error
 
-	var data_ ListOfListsOfListsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ListOfListsOfListsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -41,6 +40,6 @@ func ListOfListsOfLists(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-MultipleDirectives.graphql-MultipleDirectives.graphql.go b/generate/testdata/snapshots/TestGenerate-MultipleDirectives.graphql-MultipleDirectives.graphql.go
index 2859ade..5946191 100644
--- a/generate/testdata/snapshots/TestGenerate-MultipleDirectives.graphql-MultipleDirectives.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-MultipleDirectives.graphql-MultipleDirectives.graphql.go
@@ -325,7 +325,7 @@ func (v *__MultipleDirectivesInput) GetQuery() MyInput { return v.Query }
 // GetQueries returns __MultipleDirectivesInput.Queries, and is useful for accessing the field via an interface.
 func (v *__MultipleDirectivesInput) GetQueries() []*UserQueryInput { return v.Queries }
 
-// The query or mutation executed by MultipleDirectives.
+// The query executed by MultipleDirectives.
 const MultipleDirectives_Operation = `
 query MultipleDirectives ($query: UserQueryInput, $queries: [UserQueryInput]) {
 	user(query: $query) {
@@ -341,7 +341,7 @@ func MultipleDirectives(
 	client_ graphql.Client,
 	query MyInput,
 	queries []*UserQueryInput,
-) (*MyMultipleDirectivesResponse, error) {
+) (data_ *MyMultipleDirectivesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "MultipleDirectives",
 		Query:  MultipleDirectives_Operation,
@@ -350,10 +350,9 @@ func MultipleDirectives(
 			Queries: queries,
 		},
 	}
-	var err_ error
 
-	var data_ MyMultipleDirectivesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &MyMultipleDirectivesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -361,6 +360,6 @@ func MultipleDirectives(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-MutationArgsWithCollidingNames.graphql-MutationArgsWithCollidingNames.graphql.go b/generate/testdata/snapshots/TestGenerate-MutationArgsWithCollidingNames.graphql-MutationArgsWithCollidingNames.graphql.go
index be34cf2..df1af30 100644
--- a/generate/testdata/snapshots/TestGenerate-MutationArgsWithCollidingNames.graphql-MutationArgsWithCollidingNames.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-MutationArgsWithCollidingNames.graphql-MutationArgsWithCollidingNames.graphql.go
@@ -51,7 +51,7 @@ func (v *__MutationArgsWithCollidingNamesInput) GetResp() int { return v.Resp }
 // GetClient returns __MutationArgsWithCollidingNamesInput.Client, and is useful for accessing the field via an interface.
 func (v *__MutationArgsWithCollidingNamesInput) GetClient() string { return v.Client }
 
-// The query or mutation executed by MutationArgsWithCollidingNames.
+// The mutation executed by MutationArgsWithCollidingNames.
 const MutationArgsWithCollidingNames_Operation = `
 mutation MutationArgsWithCollidingNames ($data: String!, $req: Int, $resp: Int, $client: String) {
 	updateUser(data: $data, req: $req, resp: $resp, client: $client) {
@@ -66,7 +66,7 @@ func MutationArgsWithCollidingNames(
 	req int,
 	resp int,
 	client string,
-) (*MutationArgsWithCollidingNamesResponse, error) {
+) (data_ *MutationArgsWithCollidingNamesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "MutationArgsWithCollidingNames",
 		Query:  MutationArgsWithCollidingNames_Operation,
@@ -77,10 +77,9 @@ func MutationArgsWithCollidingNames(
 			Client: client,
 		},
 	}
-	var err_ error
 
-	var data_ MutationArgsWithCollidingNamesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &MutationArgsWithCollidingNamesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -88,6 +87,6 @@ func MutationArgsWithCollidingNames(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go b/generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go
index a0f3cf1..5ad9ffe 100644
--- a/generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go
@@ -219,7 +219,7 @@ func (v *__OmitEmptyQueryInput) GetTz() string { return v.Tz }
 // GetTzNoOmitEmpty returns __OmitEmptyQueryInput.TzNoOmitEmpty, and is useful for accessing the field via an interface.
 func (v *__OmitEmptyQueryInput) GetTzNoOmitEmpty() string { return v.TzNoOmitEmpty }
 
-// The query or mutation executed by OmitEmptyQuery.
+// The query executed by OmitEmptyQuery.
 const OmitEmptyQuery_Operation = `
 query OmitEmptyQuery ($query: UserQueryInput, $queries: [UserQueryInput], $dt: DateTime, $tz: String, $tzNoOmitEmpty: String) {
 	user(query: $query) {
@@ -240,7 +240,7 @@ func OmitEmptyQuery(
 	dt time.Time,
 	tz string,
 	tzNoOmitEmpty string,
-) (*OmitEmptyQueryResponse, error) {
+) (data_ *OmitEmptyQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "OmitEmptyQuery",
 		Query:  OmitEmptyQuery_Operation,
@@ -252,10 +252,9 @@ func OmitEmptyQuery(
 			TzNoOmitEmpty: tzNoOmitEmpty,
 		},
 	}
-	var err_ error
 
-	var data_ OmitEmptyQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &OmitEmptyQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -263,6 +262,6 @@ func OmitEmptyQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-OmitemptyFalse.graphql-OmitemptyFalse.graphql.go b/generate/testdata/snapshots/TestGenerate-OmitemptyFalse.graphql-OmitemptyFalse.graphql.go
index 74b81eb..ccb8ed7 100644
--- a/generate/testdata/snapshots/TestGenerate-OmitemptyFalse.graphql-OmitemptyFalse.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-OmitemptyFalse.graphql-OmitemptyFalse.graphql.go
@@ -33,7 +33,7 @@ type __OmitemptyFalseInput struct {
 // GetInput returns __OmitemptyFalseInput.Input, and is useful for accessing the field via an interface.
 func (v *__OmitemptyFalseInput) GetInput() OmitemptyInput { return v.Input }
 
-// The query or mutation executed by OmitemptyFalse.
+// The query executed by OmitemptyFalse.
 const OmitemptyFalse_Operation = `
 query OmitemptyFalse ($input: OmitemptyInput) {
 	omitempty(input: $input)
@@ -43,7 +43,7 @@ query OmitemptyFalse ($input: OmitemptyInput) {
 func OmitemptyFalse(
 	client_ graphql.Client,
 	input OmitemptyInput,
-) (*OmitemptyFalseResponse, error) {
+) (data_ *OmitemptyFalseResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "OmitemptyFalse",
 		Query:  OmitemptyFalse_Operation,
@@ -51,10 +51,9 @@ func OmitemptyFalse(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ OmitemptyFalseResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &OmitemptyFalseResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -62,6 +61,6 @@ func OmitemptyFalse(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Pointers.graphql-Pointers.graphql.go b/generate/testdata/snapshots/TestGenerate-Pointers.graphql-Pointers.graphql.go
index 7b40273..37dce39 100644
--- a/generate/testdata/snapshots/TestGenerate-Pointers.graphql-Pointers.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Pointers.graphql-Pointers.graphql.go
@@ -230,7 +230,7 @@ func (v *__PointersQueryInput) GetDt() time.Time { return v.Dt }
 // GetTz returns __PointersQueryInput.Tz, and is useful for accessing the field via an interface.
 func (v *__PointersQueryInput) GetTz() *string { return v.Tz }
 
-// The query or mutation executed by PointersQuery.
+// The query executed by PointersQuery.
 const PointersQuery_Operation = `
 query PointersQuery ($query: UserQueryInput, $dt: DateTime, $tz: String) {
 	user(query: $query) {
@@ -252,7 +252,7 @@ func PointersQuery(
 	query *UserQueryInput,
 	dt time.Time,
 	tz *string,
-) (*PointersQueryResponse, error) {
+) (data_ *PointersQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "PointersQuery",
 		Query:  PointersQuery_Operation,
@@ -262,10 +262,9 @@ func PointersQuery(
 			Tz:    tz,
 		},
 	}
-	var err_ error
 
-	var data_ PointersQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &PointersQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -273,6 +272,6 @@ func PointersQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-PointersInline.graphql-PointersInline.graphql.go b/generate/testdata/snapshots/TestGenerate-PointersInline.graphql-PointersInline.graphql.go
index b365f37..aa1877e 100644
--- a/generate/testdata/snapshots/TestGenerate-PointersInline.graphql-PointersInline.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-PointersInline.graphql-PointersInline.graphql.go
@@ -227,7 +227,7 @@ func (v *__PointersQueryInput) GetDt() *time.Time { return v.Dt }
 // GetTz returns __PointersQueryInput.Tz, and is useful for accessing the field via an interface.
 func (v *__PointersQueryInput) GetTz() string { return v.Tz }
 
-// The query or mutation executed by PointersQuery.
+// The query executed by PointersQuery.
 const PointersQuery_Operation = `
 query PointersQuery ($query: UserQueryInput, $dt: DateTime, $tz: String) {
 	user(query: $query) {
@@ -249,7 +249,7 @@ func PointersQuery(
 	query *UserQueryInput,
 	dt *time.Time,
 	tz string,
-) (*PointersQueryResponse, error) {
+) (data_ *PointersQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "PointersQuery",
 		Query:  PointersQuery_Operation,
@@ -259,10 +259,9 @@ func PointersQuery(
 			Tz:    tz,
 		},
 	}
-	var err_ error
 
-	var data_ PointersQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &PointersQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -270,6 +269,6 @@ func PointersQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Pokemon.graphql-Pokemon.graphql.go b/generate/testdata/snapshots/TestGenerate-Pokemon.graphql-Pokemon.graphql.go
index 9f1b108..cce522b 100644
--- a/generate/testdata/snapshots/TestGenerate-Pokemon.graphql-Pokemon.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Pokemon.graphql-Pokemon.graphql.go
@@ -71,7 +71,7 @@ type __GetPokemonSiblingsInput struct {
 // GetInput returns __GetPokemonSiblingsInput.Input, and is useful for accessing the field via an interface.
 func (v *__GetPokemonSiblingsInput) GetInput() testutil.Pokemon { return v.Input }
 
-// The query or mutation executed by GetPokemonSiblings.
+// The query executed by GetPokemonSiblings.
 const GetPokemonSiblings_Operation = `
 query GetPokemonSiblings ($input: PokemonInput!) {
 	user(query: {hasPokemon:$input}) {
@@ -93,7 +93,7 @@ query GetPokemonSiblings ($input: PokemonInput!) {
 func GetPokemonSiblings(
 	client_ graphql.Client,
 	input testutil.Pokemon,
-) (*GetPokemonSiblingsResponse, error) {
+) (data_ *GetPokemonSiblingsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "GetPokemonSiblings",
 		Query:  GetPokemonSiblings_Operation,
@@ -101,10 +101,9 @@ func GetPokemonSiblings(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ GetPokemonSiblingsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &GetPokemonSiblingsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -112,6 +111,6 @@ func GetPokemonSiblings(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-QueryWithAlias.graphql-QueryWithAlias.graphql.go b/generate/testdata/snapshots/TestGenerate-QueryWithAlias.graphql-QueryWithAlias.graphql.go
index 0a71a8a..11f0856 100644
--- a/generate/testdata/snapshots/TestGenerate-QueryWithAlias.graphql-QueryWithAlias.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-QueryWithAlias.graphql-QueryWithAlias.graphql.go
@@ -40,7 +40,7 @@ func (v *QueryWithAliasUser) GetID() testutil.ID { return v.ID }
 // GetOtherID returns QueryWithAliasUser.OtherID, and is useful for accessing the field via an interface.
 func (v *QueryWithAliasUser) GetOtherID() testutil.ID { return v.OtherID }
 
-// The query or mutation executed by QueryWithAlias.
+// The query executed by QueryWithAlias.
 const QueryWithAlias_Operation = `
 query QueryWithAlias {
 	User: user {
@@ -52,15 +52,14 @@ query QueryWithAlias {
 
 func QueryWithAlias(
 	client_ graphql.Client,
-) (*QueryWithAliasResponse, error) {
+) (data_ *QueryWithAliasResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithAlias",
 		Query:  QueryWithAlias_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithAliasResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithAliasResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -68,6 +67,6 @@ func QueryWithAlias(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-QueryWithDoubleAlias.graphql-QueryWithDoubleAlias.graphql.go b/generate/testdata/snapshots/TestGenerate-QueryWithDoubleAlias.graphql-QueryWithDoubleAlias.graphql.go
index f921fc5..3b1f1f0 100644
--- a/generate/testdata/snapshots/TestGenerate-QueryWithDoubleAlias.graphql-QueryWithDoubleAlias.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-QueryWithDoubleAlias.graphql-QueryWithDoubleAlias.graphql.go
@@ -40,7 +40,7 @@ func (v *QueryWithDoubleAliasUser) GetID() testutil.ID { return v.ID }
 // GetAlsoID returns QueryWithDoubleAliasUser.AlsoID, and is useful for accessing the field via an interface.
 func (v *QueryWithDoubleAliasUser) GetAlsoID() testutil.ID { return v.AlsoID }
 
-// The query or mutation executed by QueryWithDoubleAlias.
+// The query executed by QueryWithDoubleAlias.
 const QueryWithDoubleAlias_Operation = `
 query QueryWithDoubleAlias {
 	user {
@@ -52,15 +52,14 @@ query QueryWithDoubleAlias {
 
 func QueryWithDoubleAlias(
 	client_ graphql.Client,
-) (*QueryWithDoubleAliasResponse, error) {
+) (data_ *QueryWithDoubleAliasResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithDoubleAlias",
 		Query:  QueryWithDoubleAlias_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithDoubleAliasResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithDoubleAliasResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -68,6 +67,6 @@ func QueryWithDoubleAlias(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-QueryWithEnums.graphql-QueryWithEnums.graphql.go b/generate/testdata/snapshots/TestGenerate-QueryWithEnums.graphql-QueryWithEnums.graphql.go
index b3b0a42..e92ac51 100644
--- a/generate/testdata/snapshots/TestGenerate-QueryWithEnums.graphql-QueryWithEnums.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-QueryWithEnums.graphql-QueryWithEnums.graphql.go
@@ -62,7 +62,7 @@ const (
 	RoleTeacher Role = "TEACHER"
 )
 
-// The query or mutation executed by QueryWithEnums.
+// The query executed by QueryWithEnums.
 const QueryWithEnums_Operation = `
 query QueryWithEnums {
 	user {
@@ -76,15 +76,14 @@ query QueryWithEnums {
 
 func QueryWithEnums(
 	client_ graphql.Client,
-) (*QueryWithEnumsResponse, error) {
+) (data_ *QueryWithEnumsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithEnums",
 		Query:  QueryWithEnums_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithEnumsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithEnumsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -92,6 +91,6 @@ func QueryWithEnums(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-QueryWithSlices.graphql-QueryWithSlices.graphql.go b/generate/testdata/snapshots/TestGenerate-QueryWithSlices.graphql-QueryWithSlices.graphql.go
index 8c2b7a6..5fe2c87 100644
--- a/generate/testdata/snapshots/TestGenerate-QueryWithSlices.graphql-QueryWithSlices.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-QueryWithSlices.graphql-QueryWithSlices.graphql.go
@@ -41,7 +41,7 @@ func (v *QueryWithSlicesUser) GetEmailsWithNulls() []string { return v.EmailsWit
 // GetEmailsWithNullsOrNull returns QueryWithSlicesUser.EmailsWithNullsOrNull, and is useful for accessing the field via an interface.
 func (v *QueryWithSlicesUser) GetEmailsWithNullsOrNull() []string { return v.EmailsWithNullsOrNull }
 
-// The query or mutation executed by QueryWithSlices.
+// The query executed by QueryWithSlices.
 const QueryWithSlices_Operation = `
 query QueryWithSlices {
 	user {
@@ -55,15 +55,14 @@ query QueryWithSlices {
 
 func QueryWithSlices(
 	client_ graphql.Client,
-) (*QueryWithSlicesResponse, error) {
+) (data_ *QueryWithSlicesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithSlices",
 		Query:  QueryWithSlices_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithSlicesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithSlicesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -71,6 +70,6 @@ func QueryWithSlices(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-QueryWithStructs.graphql-QueryWithStructs.graphql.go b/generate/testdata/snapshots/TestGenerate-QueryWithStructs.graphql-QueryWithStructs.graphql.go
index 8146c98..3e2ba9d 100644
--- a/generate/testdata/snapshots/TestGenerate-QueryWithStructs.graphql-QueryWithStructs.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-QueryWithStructs.graphql-QueryWithStructs.graphql.go
@@ -43,7 +43,7 @@ func (v *QueryWithStructsUserAuthMethodsAuthMethod) GetProvider() string { retur
 // GetEmail returns QueryWithStructsUserAuthMethodsAuthMethod.Email, and is useful for accessing the field via an interface.
 func (v *QueryWithStructsUserAuthMethodsAuthMethod) GetEmail() string { return v.Email }
 
-// The query or mutation executed by QueryWithStructs.
+// The query executed by QueryWithStructs.
 const QueryWithStructs_Operation = `
 query QueryWithStructs {
 	user {
@@ -57,15 +57,14 @@ query QueryWithStructs {
 
 func QueryWithStructs(
 	client_ graphql.Client,
-) (*QueryWithStructsResponse, error) {
+) (data_ *QueryWithStructsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithStructs",
 		Query:  QueryWithStructs_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithStructsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithStructsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -73,6 +72,6 @@ func QueryWithStructs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-Recursion.graphql-Recursion.graphql.go b/generate/testdata/snapshots/TestGenerate-Recursion.graphql-Recursion.graphql.go
index 9c479e0..b95cf54 100644
--- a/generate/testdata/snapshots/TestGenerate-Recursion.graphql-Recursion.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-Recursion.graphql-Recursion.graphql.go
@@ -68,7 +68,7 @@ type __RecursionInput struct {
 // GetInput returns __RecursionInput.Input, and is useful for accessing the field via an interface.
 func (v *__RecursionInput) GetInput() RecursiveInput { return v.Input }
 
-// The query or mutation executed by Recursion.
+// The query executed by Recursion.
 const Recursion_Operation = `
 query Recursion ($input: RecursiveInput!) {
 	recur(input: $input) {
@@ -86,7 +86,7 @@ query Recursion ($input: RecursiveInput!) {
 func Recursion(
 	client_ graphql.Client,
 	input RecursiveInput,
-) (*RecursionResponse, error) {
+) (data_ *RecursionResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "Recursion",
 		Query:  Recursion_Operation,
@@ -94,10 +94,9 @@ func Recursion(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ RecursionResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &RecursionResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -105,6 +104,6 @@ func Recursion(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleInlineFragment.graphql-SimpleInlineFragment.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleInlineFragment.graphql-SimpleInlineFragment.graphql.go
index 0d3fb54..ba39163 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleInlineFragment.graphql-SimpleInlineFragment.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleInlineFragment.graphql-SimpleInlineFragment.graphql.go
@@ -239,7 +239,7 @@ func (v *SimpleInlineFragmentResponse) __premarshalJSON() (*__premarshalSimpleIn
 	return &retval, nil
 }
 
-// The query or mutation executed by SimpleInlineFragment.
+// The query executed by SimpleInlineFragment.
 const SimpleInlineFragment_Operation = `
 query SimpleInlineFragment {
 	randomItem {
@@ -258,15 +258,14 @@ query SimpleInlineFragment {
 
 func SimpleInlineFragment(
 	client_ graphql.Client,
-) (*SimpleInlineFragmentResponse, error) {
+) (data_ *SimpleInlineFragmentResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleInlineFragment",
 		Query:  SimpleInlineFragment_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleInlineFragmentResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleInlineFragmentResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -274,6 +273,6 @@ func SimpleInlineFragment(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleInput.graphql-SimpleInput.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleInput.graphql-SimpleInput.graphql.go
index f6e475e..2ecfa74 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleInput.graphql-SimpleInput.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleInput.graphql-SimpleInput.graphql.go
@@ -41,7 +41,7 @@ type __SimpleInputQueryInput struct {
 // GetName returns __SimpleInputQueryInput.Name, and is useful for accessing the field via an interface.
 func (v *__SimpleInputQueryInput) GetName() string { return v.Name }
 
-// The query or mutation executed by SimpleInputQuery.
+// The query executed by SimpleInputQuery.
 const SimpleInputQuery_Operation = `
 query SimpleInputQuery ($name: String!) {
 	user(query: {name:$name}) {
@@ -53,7 +53,7 @@ query SimpleInputQuery ($name: String!) {
 func SimpleInputQuery(
 	client_ graphql.Client,
 	name string,
-) (*SimpleInputQueryResponse, error) {
+) (data_ *SimpleInputQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleInputQuery",
 		Query:  SimpleInputQuery_Operation,
@@ -61,10 +61,9 @@ func SimpleInputQuery(
 			Name: name,
 		},
 	}
-	var err_ error
 
-	var data_ SimpleInputQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleInputQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -72,6 +71,6 @@ func SimpleInputQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleMutation.graphql-SimpleMutation.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleMutation.graphql-SimpleMutation.graphql.go
index f87244c..6a6df45 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleMutation.graphql-SimpleMutation.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleMutation.graphql-SimpleMutation.graphql.go
@@ -41,7 +41,7 @@ type __SimpleMutationInput struct {
 // GetName returns __SimpleMutationInput.Name, and is useful for accessing the field via an interface.
 func (v *__SimpleMutationInput) GetName() string { return v.Name }
 
-// The query or mutation executed by SimpleMutation.
+// The mutation executed by SimpleMutation.
 const SimpleMutation_Operation = `
 mutation SimpleMutation ($name: String!) {
 	createUser(name: $name) {
@@ -58,7 +58,7 @@ mutation SimpleMutation ($name: String!) {
 func SimpleMutation(
 	client_ graphql.Client,
 	name string,
-) (*SimpleMutationResponse, error) {
+) (data_ *SimpleMutationResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleMutation",
 		Query:  SimpleMutation_Operation,
@@ -66,10 +66,9 @@ func SimpleMutation(
 			Name: name,
 		},
 	}
-	var err_ error
 
-	var data_ SimpleMutationResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleMutationResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -77,6 +76,6 @@ func SimpleMutation(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleNamedFragment.graphql-SimpleNamedFragment.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleNamedFragment.graphql-SimpleNamedFragment.graphql.go
index c0ee332..c9fd12a 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleNamedFragment.graphql-SimpleNamedFragment.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleNamedFragment.graphql-SimpleNamedFragment.graphql.go
@@ -546,7 +546,7 @@ type VideoFieldsThumbnail struct {
 // GetId returns VideoFieldsThumbnail.Id, and is useful for accessing the field via an interface.
 func (v *VideoFieldsThumbnail) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by SimpleNamedFragment.
+// The query executed by SimpleNamedFragment.
 const SimpleNamedFragment_Operation = `
 query SimpleNamedFragment {
 	randomItem {
@@ -573,15 +573,14 @@ fragment VideoFields on Video {
 
 func SimpleNamedFragment(
 	client_ graphql.Client,
-) (*SimpleNamedFragmentResponse, error) {
+) (data_ *SimpleNamedFragmentResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleNamedFragment",
 		Query:  SimpleNamedFragment_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleNamedFragmentResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleNamedFragmentResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -589,6 +588,6 @@ func SimpleNamedFragment(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleQuery.graphql-SimpleQuery.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleQuery.graphql-SimpleQuery.graphql.go
index ddb81cf..2b67d70 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleQuery.graphql-SimpleQuery.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleQuery.graphql-SimpleQuery.graphql.go
@@ -33,7 +33,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -44,15 +44,14 @@ query SimpleQuery {
 
 func SimpleQuery(
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -60,6 +59,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleQueryNoOverride.graphql-SimpleQueryNoOverride.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleQueryNoOverride.graphql-SimpleQueryNoOverride.graphql.go
index 6458168..b50c73c 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleQueryNoOverride.graphql-SimpleQueryNoOverride.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleQueryNoOverride.graphql-SimpleQueryNoOverride.graphql.go
@@ -37,7 +37,7 @@ func (v *SimpleQueryNoOverrideUser) GetId() testutil.ID { return v.Id }
 // GetName returns SimpleQueryNoOverrideUser.Name, and is useful for accessing the field via an interface.
 func (v *SimpleQueryNoOverrideUser) GetName() string { return v.Name }
 
-// The query or mutation executed by SimpleQueryNoOverride.
+// The query executed by SimpleQueryNoOverride.
 const SimpleQueryNoOverride_Operation = `
 query SimpleQueryNoOverride {
 	user {
@@ -49,15 +49,14 @@ query SimpleQueryNoOverride {
 
 func SimpleQueryNoOverride(
 	client_ graphql.Client,
-) (*SimpleQueryNoOverrideResponse, error) {
+) (data_ *SimpleQueryNoOverrideResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQueryNoOverride",
 		Query:  SimpleQueryNoOverride_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryNoOverrideResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryNoOverrideResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -65,6 +64,6 @@ func SimpleQueryNoOverride(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleQueryWithPointerFalseOverride.graphql-SimpleQueryWithPointerFalseOverride.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleQueryWithPointerFalseOverride.graphql-SimpleQueryWithPointerFalseOverride.graphql.go
index 6c26ddb..d0d6fff 100644
--- a/generate/testdata/snapshots/TestGenerate-SimpleQueryWithPointerFalseOverride.graphql-SimpleQueryWithPointerFalseOverride.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-SimpleQueryWithPointerFalseOverride.graphql-SimpleQueryWithPointerFalseOverride.graphql.go
@@ -39,7 +39,7 @@ func (v *SimpleQueryWithPointerFalseOverrideUser) GetId() testutil.ID { return v
 // GetName returns SimpleQueryWithPointerFalseOverrideUser.Name, and is useful for accessing the field via an interface.
 func (v *SimpleQueryWithPointerFalseOverrideUser) GetName() string { return v.Name }
 
-// The query or mutation executed by SimpleQueryWithPointerFalseOverride.
+// The query executed by SimpleQueryWithPointerFalseOverride.
 const SimpleQueryWithPointerFalseOverride_Operation = `
 query SimpleQueryWithPointerFalseOverride {
 	user {
@@ -51,15 +51,14 @@ query SimpleQueryWithPointerFalseOverride {
 
 func SimpleQueryWithPointerFalseOverride(
 	client_ graphql.Client,
-) (*SimpleQueryWithPointerFalseOverrideResponse, error) {
+) (data_ *SimpleQueryWithPointerFalseOverrideResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQueryWithPointerFalseOverride",
 		Query:  SimpleQueryWithPointerFalseOverride_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryWithPointerFalseOverrideResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryWithPointerFalseOverrideResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -67,6 +66,6 @@ func SimpleQueryWithPointerFalseOverride(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.go b/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.go
new file mode 100644
index 0000000..4f1ebca
--- /dev/null
+++ b/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.go
@@ -0,0 +1,70 @@
+// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
+
+package test
+
+import (
+	"encoding/json"
+	"errors"
+
+	"github.com/Khan/genqlient/graphql"
+)
+
+// SimpleSubscriptionResponse is returned by SimpleSubscription on success.
+type SimpleSubscriptionResponse struct {
+	Count int `json:"count"`
+}
+
+// GetCount returns SimpleSubscriptionResponse.Count, and is useful for accessing the field via an interface.
+func (v *SimpleSubscriptionResponse) GetCount() int { return v.Count }
+
+// The subscription executed by SimpleSubscription.
+const SimpleSubscription_Operation = `
+subscription SimpleSubscription {
+	count
+}
+`
+
+// To unsubscribe, use [graphql.WebSocketClient.Unsubscribe]
+func SimpleSubscription(
+	client_ graphql.WebSocketClient,
+) (dataChan_ chan SimpleSubscriptionWsResponse, subscriptionID_ string, err_ error) {
+	req_ := &graphql.Request{
+		OpName: "SimpleSubscription",
+		Query:  SimpleSubscription_Operation,
+	}
+
+	dataChan_ = make(chan SimpleSubscriptionWsResponse)
+	subscriptionID_, err_ = client_.Subscribe(req_, dataChan_, SimpleSubscriptionForwardData)
+
+	return dataChan_, subscriptionID_, err_
+}
+
+type SimpleSubscriptionWsResponse struct {
+	Data       *SimpleSubscriptionResponse `json:"data"`
+	Extensions map[string]interface{}      `json:"extensions,omitempty"`
+	Errors     error                       `json:"errors"`
+}
+
+func SimpleSubscriptionForwardData(interfaceChan interface{}, jsonRawMsg json.RawMessage) error {
+	var gqlResp graphql.Response
+	var wsResp SimpleSubscriptionWsResponse
+	err := json.Unmarshal(jsonRawMsg, &gqlResp)
+	if err != nil {
+		return err
+	}
+	if len(gqlResp.Errors) == 0 {
+		err = json.Unmarshal(jsonRawMsg, &wsResp)
+		if err != nil {
+			return err
+		}
+	} else {
+		wsResp.Errors = gqlResp.Errors
+	}
+	dataChan_, ok := interfaceChan.(chan SimpleSubscriptionWsResponse)
+	if !ok {
+		return errors.New("failed to cast interface into 'chan SimpleSubscriptionWsResponse'")
+	}
+	dataChan_ <- wsResp
+	return nil
+}
+
diff --git a/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.json b/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.json
new file mode 100644
index 0000000..6a4193c
--- /dev/null
+++ b/generate/testdata/snapshots/TestGenerate-SimpleSubscription.graphql-SimpleSubscription.graphql.json
@@ -0,0 +1,9 @@
+{
+  "operations": [
+    {
+      "operationName": "SimpleSubscription",
+      "query": "\nsubscription SimpleSubscription {\n\tcount\n}\n",
+      "sourceLocation": "testdata/queries/SimpleSubscription.graphql"
+    }
+  ]
+}
diff --git a/generate/testdata/snapshots/TestGenerate-StructOption.graphql-StructOption.graphql.go b/generate/testdata/snapshots/TestGenerate-StructOption.graphql-StructOption.graphql.go
index 55e0bfd..8c6edec 100644
--- a/generate/testdata/snapshots/TestGenerate-StructOption.graphql-StructOption.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-StructOption.graphql-StructOption.graphql.go
@@ -424,7 +424,7 @@ type VideoFields struct {
 // GetDuration returns VideoFields.Duration, and is useful for accessing the field via an interface.
 func (v *VideoFields) GetDuration() int { return v.Duration }
 
-// The query or mutation executed by StructOption.
+// The query executed by StructOption.
 const StructOption_Operation = `
 query StructOption {
 	root {
@@ -457,15 +457,14 @@ fragment VideoFields on Video {
 
 func StructOption(
 	client_ graphql.Client,
-) (*StructOptionResponse, error) {
+) (data_ *StructOptionResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "StructOption",
 		Query:  StructOption_Operation,
 	}
-	var err_ error
 
-	var data_ StructOptionResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &StructOptionResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -473,6 +472,6 @@ func StructOption(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-TypeName.graphql-TypeName.graphql.go b/generate/testdata/snapshots/TestGenerate-TypeName.graphql-TypeName.graphql.go
index af67320..2525a47 100644
--- a/generate/testdata/snapshots/TestGenerate-TypeName.graphql-TypeName.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-TypeName.graphql-TypeName.graphql.go
@@ -37,7 +37,7 @@ func (v *TypeNameQueryUser) GetTypename() string { return v.Typename }
 // GetId returns TypeNameQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *TypeNameQueryUser) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by TypeNameQuery.
+// The query executed by TypeNameQuery.
 const TypeNameQuery_Operation = `
 query TypeNameQuery {
 	user {
@@ -49,15 +49,14 @@ query TypeNameQuery {
 
 func TypeNameQuery(
 	client_ graphql.Client,
-) (*TypeNameQueryResponse, error) {
+) (data_ *TypeNameQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "TypeNameQuery",
 		Query:  TypeNameQuery_Operation,
 	}
-	var err_ error
 
-	var data_ TypeNameQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &TypeNameQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -65,6 +64,6 @@ func TypeNameQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-TypeNames.graphql-TypeNames.graphql.go b/generate/testdata/snapshots/TestGenerate-TypeNames.graphql-TypeNames.graphql.go
index 04bcec4..5272fd9 100644
--- a/generate/testdata/snapshots/TestGenerate-TypeNames.graphql-TypeNames.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-TypeNames.graphql-TypeNames.graphql.go
@@ -264,7 +264,7 @@ func (v *User) GetId() testutil.ID { return v.Id }
 // GetName returns User.Name, and is useful for accessing the field via an interface.
 func (v *User) GetName() string { return v.Name }
 
-// The query or mutation executed by TypeNames.
+// The query executed by TypeNames.
 const TypeNames_Operation = `
 query TypeNames {
 	user {
@@ -285,15 +285,14 @@ query TypeNames {
 
 func TypeNames(
 	client_ graphql.Client,
-) (*Resp, error) {
+) (data_ *Resp, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "TypeNames",
 		Query:  TypeNames_Operation,
 	}
-	var err_ error
 
-	var data_ Resp
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &Resp{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -301,6 +300,6 @@ func TypeNames(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-UnionNoFragments.graphql-UnionNoFragments.graphql.go b/generate/testdata/snapshots/TestGenerate-UnionNoFragments.graphql-UnionNoFragments.graphql.go
index d52f31a..af3bb65 100644
--- a/generate/testdata/snapshots/TestGenerate-UnionNoFragments.graphql-UnionNoFragments.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-UnionNoFragments.graphql-UnionNoFragments.graphql.go
@@ -174,7 +174,7 @@ func (v *UnionNoFragmentsQueryResponse) __premarshalJSON() (*__premarshalUnionNo
 	return &retval, nil
 }
 
-// The query or mutation executed by UnionNoFragmentsQuery.
+// The query executed by UnionNoFragmentsQuery.
 const UnionNoFragmentsQuery_Operation = `
 query UnionNoFragmentsQuery {
 	randomLeaf {
@@ -185,15 +185,14 @@ query UnionNoFragmentsQuery {
 
 func UnionNoFragmentsQuery(
 	client_ graphql.Client,
-) (*UnionNoFragmentsQueryResponse, error) {
+) (data_ *UnionNoFragmentsQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "UnionNoFragmentsQuery",
 		Query:  UnionNoFragmentsQuery_Operation,
 	}
-	var err_ error
 
-	var data_ UnionNoFragmentsQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &UnionNoFragmentsQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -201,6 +200,6 @@ func UnionNoFragmentsQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-UseStructReference.graphql-UseStructReference.graphql.go b/generate/testdata/snapshots/TestGenerate-UseStructReference.graphql-UseStructReference.graphql.go
index 09c5c6c..b42b76e 100644
--- a/generate/testdata/snapshots/TestGenerate-UseStructReference.graphql-UseStructReference.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-UseStructReference.graphql-UseStructReference.graphql.go
@@ -54,7 +54,7 @@ type __UseStructReferenceInput struct {
 // GetInput returns __UseStructReferenceInput.Input, and is useful for accessing the field via an interface.
 func (v *__UseStructReferenceInput) GetInput() UseStructReferencesInput { return v.Input }
 
-// The query or mutation executed by UseStructReference.
+// The query executed by UseStructReference.
 const UseStructReference_Operation = `
 query UseStructReference ($input: UseStructReferencesInput!) {
 	useStructReferencesInput(input: $input)
@@ -65,7 +65,7 @@ query UseStructReference ($input: UseStructReferencesInput!) {
 func UseStructReference(
 	client_ graphql.Client,
 	input UseStructReferencesInput,
-) (*UseStructReferenceResponse, error) {
+) (data_ *UseStructReferenceResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "UseStructReference",
 		Query:  UseStructReference_Operation,
@@ -73,10 +73,9 @@ func UseStructReference(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ UseStructReferenceResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &UseStructReferenceResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -84,6 +83,6 @@ func UseStructReference(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-UsesEnumTwice.graphql-UsesEnumTwice.graphql.go b/generate/testdata/snapshots/TestGenerate-UsesEnumTwice.graphql-UsesEnumTwice.graphql.go
index 69c2113..4769c04 100644
--- a/generate/testdata/snapshots/TestGenerate-UsesEnumTwice.graphql-UsesEnumTwice.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-UsesEnumTwice.graphql-UsesEnumTwice.graphql.go
@@ -62,7 +62,7 @@ func (v *UsesEnumTwiceQueryResponse) GetMe() UsesEnumTwiceQueryMeUser { return v
 // GetOtherUser returns UsesEnumTwiceQueryResponse.OtherUser, and is useful for accessing the field via an interface.
 func (v *UsesEnumTwiceQueryResponse) GetOtherUser() UsesEnumTwiceQueryOtherUser { return v.OtherUser }
 
-// The query or mutation executed by UsesEnumTwiceQuery.
+// The query executed by UsesEnumTwiceQuery.
 const UsesEnumTwiceQuery_Operation = `
 query UsesEnumTwiceQuery {
 	Me: user {
@@ -76,15 +76,14 @@ query UsesEnumTwiceQuery {
 
 func UsesEnumTwiceQuery(
 	client_ graphql.Client,
-) (*UsesEnumTwiceQueryResponse, error) {
+) (data_ *UsesEnumTwiceQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "UsesEnumTwiceQuery",
 		Query:  UsesEnumTwiceQuery_Operation,
 	}
-	var err_ error
 
-	var data_ UsesEnumTwiceQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &UsesEnumTwiceQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -92,6 +91,6 @@ func UsesEnumTwiceQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerate-unexported.graphql-unexported.graphql.go b/generate/testdata/snapshots/TestGenerate-unexported.graphql-unexported.graphql.go
index f3e1f54..8bbaabe 100644
--- a/generate/testdata/snapshots/TestGenerate-unexported.graphql-unexported.graphql.go
+++ b/generate/testdata/snapshots/TestGenerate-unexported.graphql-unexported.graphql.go
@@ -177,7 +177,7 @@ type unexportedUser struct {
 // GetId returns unexportedUser.Id, and is useful for accessing the field via an interface.
 func (v *unexportedUser) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by unexported.
+// The query executed by unexported.
 const unexported_Operation = `
 query unexported ($query: UserQueryInput) {
 	user(query: $query) {
@@ -189,7 +189,7 @@ query unexported ($query: UserQueryInput) {
 func unexported(
 	client_ graphql.Client,
 	query UserQueryInput,
-) (*unexportedResponse, error) {
+) (data_ *unexportedResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "unexported",
 		Query:  unexported_Operation,
@@ -197,10 +197,9 @@ func unexported(
 			Query: query,
 		},
 	}
-	var err_ error
 
-	var data_ unexportedResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &unexportedResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -208,6 +207,6 @@ func unexported(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetter-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetter-testdata-queries-generated.go
index 4ef93ec..d6bcce4 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetter-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetter-testdata-queries-generated.go
@@ -35,7 +35,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,12 +46,11 @@ query SimpleQuery {
 
 func SimpleQuery(
 	ctx_ context.Context,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 	var client_ graphql.Client
 
 	client_, err_ = testutil.GetClientFromContext(ctx_)
@@ -59,8 +58,8 @@ func SimpleQuery(
 		return nil, err_
 	}
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -68,6 +67,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterCustomContext-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterCustomContext-testdata-queries-generated.go
index 2a16c72..4b96971 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterCustomContext-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterCustomContext-testdata-queries-generated.go
@@ -38,7 +38,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -49,12 +49,11 @@ query SimpleQuery {
 
 func SimpleQuery(
 	ctx_ testutil.MyContext,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 	var client_ graphql.Client
 
 	client_, err_ = testutil.GetClientFromMyContext(ctx_)
@@ -62,8 +61,8 @@ func SimpleQuery(
 		return nil, err_
 	}
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -71,6 +70,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterNoContext-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterNoContext-testdata-queries-generated.go
index a34cf8d..e1ce6ef 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterNoContext-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-ClientGetterNoContext-testdata-queries-generated.go
@@ -33,7 +33,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -42,12 +42,11 @@ query SimpleQuery {
 }
 `
 
-func SimpleQuery() (*SimpleQueryResponse, error) {
+func SimpleQuery() (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 	var client_ graphql.Client
 
 	client_, err_ = testutil.GetClientFromNowhere()
@@ -55,8 +54,8 @@ func SimpleQuery() (*SimpleQueryResponse, error) {
 		return nil, err_
 	}
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -64,6 +63,6 @@ func SimpleQuery() (*SimpleQueryResponse, error) {
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-CustomContext-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-CustomContext-testdata-queries-generated.go
index e961813..58a39fe 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-CustomContext-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-CustomContext-testdata-queries-generated.go
@@ -38,7 +38,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -50,15 +50,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ testutil.MyContext,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -66,6 +65,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-CustomContextWithAlias-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-CustomContextWithAlias-testdata-queries-generated.go
index a6d2535..79d6aa4 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-CustomContextWithAlias-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-CustomContextWithAlias-testdata-queries-generated.go
@@ -38,7 +38,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -50,15 +50,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ junkfunname.MyContext,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -66,6 +65,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-DefaultConfig-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-DefaultConfig-testdata-queries-generated.go
index 2a18a3b..0c6d412 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-DefaultConfig-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-DefaultConfig-testdata-queries-generated.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingAll-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingAll-testdata-queries-generated.go
index 3d296e5..2117bc9 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingAll-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingAll-testdata-queries-generated.go
@@ -64,7 +64,7 @@ const (
 	Role_TEACHER Role = "TEACHER"
 )
 
-// The query or mutation executed by QueryWithEnums.
+// The query executed by QueryWithEnums.
 const QueryWithEnums_Operation = `
 query QueryWithEnums {
 	user {
@@ -79,15 +79,14 @@ query QueryWithEnums {
 func QueryWithEnums(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithEnumsResponse, error) {
+) (data_ *QueryWithEnumsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithEnums",
 		Query:  QueryWithEnums_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithEnumsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithEnumsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -95,6 +94,6 @@ func QueryWithEnums(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingSpecific-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingSpecific-testdata-queries-generated.go
index 3d296e5..2117bc9 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingSpecific-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingSpecific-testdata-queries-generated.go
@@ -64,7 +64,7 @@ const (
 	Role_TEACHER Role = "TEACHER"
 )
 
-// The query or mutation executed by QueryWithEnums.
+// The query executed by QueryWithEnums.
 const QueryWithEnums_Operation = `
 query QueryWithEnums {
 	user {
@@ -79,15 +79,14 @@ query QueryWithEnums {
 func QueryWithEnums(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithEnumsResponse, error) {
+) (data_ *QueryWithEnumsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithEnums",
 		Query:  QueryWithEnums_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithEnumsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithEnumsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -95,6 +94,6 @@ func QueryWithEnums(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-ExportOperations-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-ExportOperations-testdata-queries-generated.go
index 2a18a3b..0c6d412 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-ExportOperations-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-ExportOperations-testdata-queries-generated.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-Extensions-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-Extensions-testdata-queries-generated.go
index da4a5d0..e583942 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-Extensions-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-Extensions-testdata-queries-generated.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, map[string]interface{}, error) {
+) (data_ *SimpleQueryResponse, ext_ map[string]interface{}, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, resp_.Extensions, err_
+	return data_, resp_.Extensions, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-NoContext-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-NoContext-testdata-queries-generated.go
index 01005a7..7322f85 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-NoContext-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-NoContext-testdata-queries-generated.go
@@ -32,7 +32,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -43,15 +43,14 @@ query SimpleQuery {
 
 func SimpleQuery(
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		nil,
@@ -59,6 +58,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalGeneric-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalGeneric-testdata-queries-generated.go
index 5d7d29c..29b8d9e 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalGeneric-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalGeneric-testdata-queries-generated.go
@@ -82,7 +82,7 @@ type __ListInputQueryInput struct {
 // GetNames returns __ListInputQueryInput.Names, and is useful for accessing the field via an interface.
 func (v *__ListInputQueryInput) GetNames() []testutil.Option[string] { return v.Names }
 
-// The query or mutation executed by ListInputQuery.
+// The query executed by ListInputQuery.
 const ListInputQuery_Operation = `
 query ListInputQuery ($names: [String]) {
 	user(query: {names:$names}) {
@@ -95,7 +95,7 @@ func ListInputQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	names []testutil.Option[string],
-) (*ListInputQueryResponse, error) {
+) (data_ *ListInputQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ListInputQuery",
 		Query:  ListInputQuery_Operation,
@@ -103,10 +103,9 @@ func ListInputQuery(
 			Names: names,
 		},
 	}
-	var err_ error
 
-	var data_ ListInputQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ListInputQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -114,10 +113,10 @@ func ListInputQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by QueryWithSlices.
+// The query executed by QueryWithSlices.
 const QueryWithSlices_Operation = `
 query QueryWithSlices {
 	user {
@@ -132,15 +131,14 @@ query QueryWithSlices {
 func QueryWithSlices(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithSlicesResponse, error) {
+) (data_ *QueryWithSlicesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithSlices",
 		Query:  QueryWithSlices_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithSlicesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithSlicesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -148,6 +146,6 @@ func QueryWithSlices(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalPointer-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalPointer-testdata-queries-generated.go
index 781bc54..da8ee58 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalPointer-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalPointer-testdata-queries-generated.go
@@ -139,7 +139,7 @@ type __ListInputQueryInput struct {
 // GetNames returns __ListInputQueryInput.Names, and is useful for accessing the field via an interface.
 func (v *__ListInputQueryInput) GetNames() []*string { return v.Names }
 
-// The query or mutation executed by ListInputQuery.
+// The query executed by ListInputQuery.
 const ListInputQuery_Operation = `
 query ListInputQuery ($names: [String]) {
 	user(query: {names:$names}) {
@@ -152,7 +152,7 @@ func ListInputQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	names []*string,
-) (*ListInputQueryResponse, error) {
+) (data_ *ListInputQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ListInputQuery",
 		Query:  ListInputQuery_Operation,
@@ -160,10 +160,9 @@ func ListInputQuery(
 			Names: names,
 		},
 	}
-	var err_ error
 
-	var data_ ListInputQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ListInputQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -171,10 +170,10 @@ func ListInputQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by QueryWithSlices.
+// The query executed by QueryWithSlices.
 const QueryWithSlices_Operation = `
 query QueryWithSlices {
 	user {
@@ -189,15 +188,14 @@ query QueryWithSlices {
 func QueryWithSlices(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithSlicesResponse, error) {
+) (data_ *QueryWithSlicesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithSlices",
 		Query:  QueryWithSlices_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithSlicesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithSlicesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -205,10 +203,10 @@ func QueryWithSlices(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by SimpleQueryNoOverride.
+// The query executed by SimpleQueryNoOverride.
 const SimpleQueryNoOverride_Operation = `
 query SimpleQueryNoOverride {
 	user {
@@ -221,15 +219,14 @@ query SimpleQueryNoOverride {
 func SimpleQueryNoOverride(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryNoOverrideResponse, error) {
+) (data_ *SimpleQueryNoOverrideResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQueryNoOverride",
 		Query:  SimpleQueryNoOverride_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryNoOverrideResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryNoOverrideResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -237,10 +234,10 @@ func SimpleQueryNoOverride(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by SimpleQueryWithPointerFalseOverride.
+// The query executed by SimpleQueryWithPointerFalseOverride.
 const SimpleQueryWithPointerFalseOverride_Operation = `
 query SimpleQueryWithPointerFalseOverride {
 	user {
@@ -253,15 +250,14 @@ query SimpleQueryWithPointerFalseOverride {
 func SimpleQueryWithPointerFalseOverride(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryWithPointerFalseOverrideResponse, error) {
+) (data_ *SimpleQueryWithPointerFalseOverrideResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQueryWithPointerFalseOverride",
 		Query:  SimpleQueryWithPointerFalseOverride_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryWithPointerFalseOverrideResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryWithPointerFalseOverrideResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -269,6 +265,6 @@ func SimpleQueryWithPointerFalseOverride(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalValue-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalValue-testdata-queries-generated.go
index 82416cd..bdf9244 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-OptionalValue-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-OptionalValue-testdata-queries-generated.go
@@ -77,7 +77,7 @@ type __ListInputQueryInput struct {
 // GetNames returns __ListInputQueryInput.Names, and is useful for accessing the field via an interface.
 func (v *__ListInputQueryInput) GetNames() []string { return v.Names }
 
-// The query or mutation executed by ListInputQuery.
+// The query executed by ListInputQuery.
 const ListInputQuery_Operation = `
 query ListInputQuery ($names: [String]) {
 	user(query: {names:$names}) {
@@ -90,7 +90,7 @@ func ListInputQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	names []string,
-) (*ListInputQueryResponse, error) {
+) (data_ *ListInputQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "ListInputQuery",
 		Query:  ListInputQuery_Operation,
@@ -98,10 +98,9 @@ func ListInputQuery(
 			Names: names,
 		},
 	}
-	var err_ error
 
-	var data_ ListInputQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &ListInputQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -109,10 +108,10 @@ func ListInputQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by QueryWithSlices.
+// The query executed by QueryWithSlices.
 const QueryWithSlices_Operation = `
 query QueryWithSlices {
 	user {
@@ -127,15 +126,14 @@ query QueryWithSlices {
 func QueryWithSlices(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithSlicesResponse, error) {
+) (data_ *QueryWithSlicesResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithSlices",
 		Query:  QueryWithSlices_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithSlicesResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithSlicesResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -143,6 +141,6 @@ func QueryWithSlices(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-PackageBindings-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-PackageBindings-testdata-queries-generated.go
index 9340d5e..5205788 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-PackageBindings-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-PackageBindings-testdata-queries-generated.go
@@ -35,7 +35,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() testutil.ID { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -47,15 +47,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -63,6 +62,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-PackageName-testdata-queries-myfile.go b/generate/testdata/snapshots/TestGenerateWithConfig-PackageName-testdata-queries-myfile.go
index 4d38276..2be8134 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-PackageName-testdata-queries-myfile.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-PackageName-testdata-queries-myfile.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-StructReferences-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-StructReferences-testdata-queries-generated.go
index 8365a6f..507f60f 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-StructReferences-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-StructReferences-testdata-queries-generated.go
@@ -226,7 +226,7 @@ type __InputObjectQueryInput struct {
 // GetQuery returns __InputObjectQueryInput.Query, and is useful for accessing the field via an interface.
 func (v *__InputObjectQueryInput) GetQuery() *UserQueryInput { return v.Query }
 
-// The query or mutation executed by InputObjectQuery.
+// The query executed by InputObjectQuery.
 const InputObjectQuery_Operation = `
 query InputObjectQuery ($query: UserQueryInput) {
 	user(query: $query) {
@@ -239,7 +239,7 @@ func InputObjectQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	query *UserQueryInput,
-) (*InputObjectQueryResponse, error) {
+) (data_ *InputObjectQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InputObjectQuery",
 		Query:  InputObjectQuery_Operation,
@@ -247,10 +247,9 @@ func InputObjectQuery(
 			Query: query,
 		},
 	}
-	var err_ error
 
-	var data_ InputObjectQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InputObjectQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -258,10 +257,10 @@ func InputObjectQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by QueryWithStructs.
+// The query executed by QueryWithStructs.
 const QueryWithStructs_Operation = `
 query QueryWithStructs {
 	user {
@@ -276,15 +275,14 @@ query QueryWithStructs {
 func QueryWithStructs(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithStructsResponse, error) {
+) (data_ *QueryWithStructsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithStructs",
 		Query:  QueryWithStructs_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithStructsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithStructsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -292,6 +290,6 @@ func QueryWithStructs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-StructReferencesAndOptionalPointer-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-StructReferencesAndOptionalPointer-testdata-queries-generated.go
index 61c785f..7e1b2b1 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-StructReferencesAndOptionalPointer-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-StructReferencesAndOptionalPointer-testdata-queries-generated.go
@@ -229,7 +229,7 @@ type __InputObjectQueryInput struct {
 // GetQuery returns __InputObjectQueryInput.Query, and is useful for accessing the field via an interface.
 func (v *__InputObjectQueryInput) GetQuery() *UserQueryInput { return v.Query }
 
-// The query or mutation executed by InputObjectQuery.
+// The query executed by InputObjectQuery.
 const InputObjectQuery_Operation = `
 query InputObjectQuery ($query: UserQueryInput) {
 	user(query: $query) {
@@ -242,7 +242,7 @@ func InputObjectQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	query *UserQueryInput,
-) (*InputObjectQueryResponse, error) {
+) (data_ *InputObjectQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "InputObjectQuery",
 		Query:  InputObjectQuery_Operation,
@@ -250,10 +250,9 @@ func InputObjectQuery(
 			Query: query,
 		},
 	}
-	var err_ error
 
-	var data_ InputObjectQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &InputObjectQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -261,10 +260,10 @@ func InputObjectQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
-// The query or mutation executed by QueryWithStructs.
+// The query executed by QueryWithStructs.
 const QueryWithStructs_Operation = `
 query QueryWithStructs {
 	user {
@@ -279,15 +278,14 @@ query QueryWithStructs {
 func QueryWithStructs(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*QueryWithStructsResponse, error) {
+) (data_ *QueryWithStructsResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "QueryWithStructs",
 		Query:  QueryWithStructs_Operation,
 	}
-	var err_ error
 
-	var data_ QueryWithStructsResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &QueryWithStructsResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -295,6 +293,6 @@ func QueryWithStructs(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-Subpackage-testdata-queries-mypkg-myfile.go b/generate/testdata/snapshots/TestGenerateWithConfig-Subpackage-testdata-queries-mypkg-myfile.go
index 4d38276..2be8134 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-Subpackage-testdata-queries-mypkg-myfile.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-Subpackage-testdata-queries-mypkg-myfile.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-SubpackageConfig-testdata-queries-mypkg-myfile.go b/generate/testdata/snapshots/TestGenerateWithConfig-SubpackageConfig-testdata-queries-mypkg-myfile.go
index 4d38276..2be8134 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-SubpackageConfig-testdata-queries-mypkg-myfile.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-SubpackageConfig-testdata-queries-mypkg-myfile.go
@@ -34,7 +34,7 @@ type SimpleQueryUser struct {
 // GetId returns SimpleQueryUser.Id, and is useful for accessing the field via an interface.
 func (v *SimpleQueryUser) GetId() string { return v.Id }
 
-// The query or mutation executed by SimpleQuery.
+// The query executed by SimpleQuery.
 const SimpleQuery_Operation = `
 query SimpleQuery {
 	user {
@@ -46,15 +46,14 @@ query SimpleQuery {
 func SimpleQuery(
 	ctx_ context.Context,
 	client_ graphql.Client,
-) (*SimpleQueryResponse, error) {
+) (data_ *SimpleQueryResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "SimpleQuery",
 		Query:  SimpleQuery_Operation,
 	}
-	var err_ error
 
-	var data_ SimpleQueryResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &SimpleQueryResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -62,6 +61,6 @@ func SimpleQuery(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/generate/testdata/snapshots/TestGenerateWithConfig-UseStructReference-testdata-queries-generated.go b/generate/testdata/snapshots/TestGenerateWithConfig-UseStructReference-testdata-queries-generated.go
index c2c3723..c03a50f 100644
--- a/generate/testdata/snapshots/TestGenerateWithConfig-UseStructReference-testdata-queries-generated.go
+++ b/generate/testdata/snapshots/TestGenerateWithConfig-UseStructReference-testdata-queries-generated.go
@@ -56,7 +56,7 @@ type __UseStructReferenceInput struct {
 // GetInput returns __UseStructReferenceInput.Input, and is useful for accessing the field via an interface.
 func (v *__UseStructReferenceInput) GetInput() *UseStructReferencesInput { return v.Input }
 
-// The query or mutation executed by UseStructReference.
+// The query executed by UseStructReference.
 const UseStructReference_Operation = `
 query UseStructReference ($input: UseStructReferencesInput!) {
 	useStructReferencesInput(input: $input)
@@ -68,7 +68,7 @@ func UseStructReference(
 	ctx_ context.Context,
 	client_ graphql.Client,
 	input *UseStructReferencesInput,
-) (*UseStructReferenceResponse, error) {
+) (data_ *UseStructReferenceResponse, err_ error) {
 	req_ := &graphql.Request{
 		OpName: "UseStructReference",
 		Query:  UseStructReference_Operation,
@@ -76,10 +76,9 @@ func UseStructReference(
 			Input: input,
 		},
 	}
-	var err_ error
 
-	var data_ UseStructReferenceResponse
-	resp_ := &graphql.Response{Data: &data_}
+	data_ = &UseStructReferenceResponse{}
+	resp_ := &graphql.Response{Data: data_}
 
 	err_ = client_.MakeRequest(
 		ctx_,
@@ -87,6 +86,6 @@ func UseStructReference(
 		resp_,
 	)
 
-	return &data_, err_
+	return data_, err_
 }
 
diff --git a/internal/integration/integration_test.go b/internal/integration/integration_test.go
index 37b0242..301ade2 100644
--- a/internal/integration/integration_test.go
+++ b/internal/integration/integration_test.go
@@ -7,6 +7,7 @@ package integration
 
 import (
 	"context"
+	"fmt"
 	"net/http"
 	"testing"
 	"time"
@@ -56,6 +57,47 @@ func TestMutation(t *testing.T) {
 	require.Errorf(t, err, "client does not support mutations")
 }
 
+func TestSubscription(t *testing.T) {
+	_ = `# @genqlient
+	subscription count { count }`
+
+	ctx := context.Background()
+	server := server.RunServer()
+	defer server.Close()
+	wsClient := newRoundtripWebScoketClient(t, server.URL)
+
+	errChan, err := wsClient.Start(ctx)
+	require.NoError(t, err)
+
+	dataChan, subscriptionID, err := count(ctx, wsClient)
+	require.NoError(t, err)
+	defer wsClient.Close()
+	counter := 0
+	start := time.Now()
+	for loop := true; loop; {
+		select {
+		case resp, more := <-dataChan:
+			if !more {
+				loop = false
+				break
+			}
+			require.NotNil(t, resp.Data)
+			assert.Equal(t, counter, resp.Data.Count)
+			require.Nil(t, resp.Errors)
+			if time.Since(start) > time.Second*5 {
+				err = wsClient.Unsubscribe(subscriptionID)
+				require.NoError(t, err)
+				loop = false
+			}
+			counter++
+		case err := <-errChan:
+			require.NoError(t, err)
+		case <-time.After(time.Second * 10):
+			require.NoError(t, fmt.Errorf("subscription timed out"))
+		}
+	}
+}
+
 func TestServerError(t *testing.T) {
 	_ = `# @genqlient
 	query failingQuery { fail me { id } }`