Skip to content

Commit

Permalink
fix: removed type operation
Browse files Browse the repository at this point in the history
  • Loading branch information
asger-noer committed Jan 17, 2024
1 parent e2b8073 commit 4f72c83
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
18 changes: 9 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (c *GraphQLClient) Request(ctx context.Context, url string, request *Reques

// Request is a GraphQL request.
type Request struct {
OperationType Operation `json:"operationType,omitempty"`
OperationType string `json:"operationType,omitempty"`
Query string `json:"query"`
OperationName string `json:"operationName,omitempty"`
Variables map[string]interface{} `json:"variables,omitempty"`
Expand All @@ -220,15 +220,15 @@ func (r *Request) WithHeaders(headers http.Header) *Request {
}

func (r *Request) WithOperationType(operation string) *Request {
switch Operation(strings.ToLower(operation)) {
case OperationQuery:
r.OperationType = OperationQuery
case OperationMutation:
r.OperationType = OperationMutation
case OperationSubscription:
r.OperationType = OperationSubscription
switch strings.ToLower(operation) {
case "query":
r.OperationType = "query"
case "mutation":
r.OperationType = "mutation"
case "subscription":
r.OperationType = "subscription"
default:
r.OperationType = OperationQuery
r.OperationType = "query"
}

return r
Expand Down
4 changes: 2 additions & 2 deletions execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func (q *queryExecution) executeBoundaryQuery(documents []string, serviceURL str
WithVariables(variables).
WithHeaders(GetOutgoingRequestHeadersFromContext(q.ctx)).
WithOperationName(q.operationName).
WithOperationType(string(OperationQuery))
WithOperationType(queryObjectName)

partialData := make(map[string]interface{})
err := q.graphqlClient.Request(q.ctx, serviceURL, req, &partialData)
Expand All @@ -241,7 +241,7 @@ func (q *queryExecution) executeBoundaryQuery(documents []string, serviceURL str
WithVariables(variables).
WithHeaders(GetOutgoingRequestHeadersFromContext(q.ctx)).
WithOperationName(q.operationName).
WithOperationType(string(OperationQuery))
WithOperationType(queryObjectName)

err := q.graphqlClient.Request(q.ctx, serviceURL, req, &data)
return data.Result, err
Expand Down
12 changes: 0 additions & 12 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ import (
"github.com/vektah/gqlparser/v2/ast"
)

// Operation is a GraphQL operation type.
type Operation string

const (
// OperationQuery is a GraphQL query operation.
OperationQuery Operation = "query"
// OperationMutation is a GraphQL mutation operation.
OperationMutation Operation = "mutation"
// OperationSubscription is a GraphQL subscription operation.
OperationSubscription Operation = "subscription"
)

var IdFieldName = "id"

const (
Expand Down

0 comments on commit 4f72c83

Please sign in to comment.