func (s *Server) RegisterQuery(operation Operation) {
	operation.opType = opQuery
	s.queries = append(s.queries, operation)
}
RegisterQuery registers an Operation as a query that the server will recognize and
respond to.
package graphql_test
import (
	"bytes"
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"strings"
	"testing"
	"github.com/pkg/errors"
)
type Server struct {
	URL string
	mutations []Operation
	queries   []Operation
	t      *testing.T
	server *httptest.Server
}
func NewServer(t *testing.T, useDefaultOperations bool) *Server {  
	s := Server{
		t: t,
	}
	if useDefaultOperations {
		s.RegisterQuery(Operation{
			Identifier: QueryGetEntity.operationName(),
			Variables:  QueryGetEntity.Variables(),
			Response:   QueryGetEntity.ExpectedResponse(),
		})
		s.RegisterMutation(Operation{
			Identifier: MutationCreateEntity.operationName(),
			Variables:  MutationCreateEntity.Variables(),
			Response:   MutationCreateEntity.ExpectedResponse(),
		})
		s.RegisterMutation(Operation{
			Identifier: MutationUpdateEntity.operationName(),
			Variables:  MutationUpdateEntity.Variables(),
			Response:   MutationUpdateEntity.ExpectedResponse(),
		})
		s.RegisterMutation(Operation{
			Identifier: MutationDeleteEntity.operationName(),
			Variables:  MutationDeleteEntity.Variables(),
			Response:   MutationDeleteEntity.ExpectedResponse(),
		})
	}
	var mux http.ServeMux
	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		var reqBody Request
		if err := json.NewDecoder(r.Body).Decode(&reqBody); err != nil {
			s.respondError(w, http.StatusInternalServerError, errors.Wrap(err, "decode request body"))
			return
		}
		if strings.HasPrefix(strings.TrimSpace(reqBody.Query), "mutation") {
			for i := range s.mutations {
				if strings.Contains(reqBody.Query, s.mutations[i].Identifier) {
					if s.equalVariables(s.mutations[i].Variables, reqBody.Variables) {
						s.respond(w, http.StatusOK, s.mutations[i].Response)
						return
					}
				}
			}
		} else if strings.HasPrefix(strings.TrimSpace(reqBody.Query), "query") {
			for i := range s.queries {
				if strings.Contains(reqBody.Query, s.queries[i].Identifier) {
					if s.equalVariables(s.queries[i].Variables, reqBody.Variables) {
						s.respond(w, http.StatusOK, s.queries[i].Response)
						return
					}
				}
			}
		}
		s.respondError(w, http.StatusNotFound, errors.New("operation not found"))
	})
	s.server = httptest.NewServer(&mux)
	s.URL = s.server.URL
	return &s
}
func (s *Server) Close() {
	s.server.Close()
}
func (s *Server) Mutations() []Operation {
	return s.mutations
}
func (s *Server) Queries() []Operation {
	return s.queries
}