Skip to content

Commit 1988a9c

Browse files
committed
poc
1 parent c416c52 commit 1988a9c

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

pkg/engine/datasource/rest_datasource/rest_datasource.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8-
"github.com/buger/jsonparser"
98
"io"
109
"net/http"
1110
"regexp"
1211
"strings"
1312

13+
"github.com/buger/jsonparser"
14+
1415
"github.com/TykTechnologies/graphql-go-tools/pkg/ast"
1516
"github.com/TykTechnologies/graphql-go-tools/pkg/engine/datasource/httpclient"
1617
"github.com/TykTechnologies/graphql-go-tools/pkg/engine/plan"
@@ -167,8 +168,17 @@ Next:
167168
typeRef := p.v.Operation.VariableDefinitions[variableDefRef].Type
168169
typeName := p.v.Operation.TypeNameString(typeRef)
169170
typeKind := p.v.Operation.Types[typeRef].TypeKind
171+
172+
underlyingTypeName := typeName
173+
if typeKind == ast.TypeKindNonNull {
174+
underlyingTypeName = p.v.Operation.TypeNameString(p.v.Operation.Types[typeRef].OfType)
175+
}
176+
177+
node, exists := p.v.Definition.NodeByNameStr(underlyingTypeName)
178+
isEnum := exists && node.Kind == ast.NodeKindEnumTypeDefinition
179+
170180
// if type is a nullable or non-nullable string, add quotes to the raw message
171-
if typeName == typeString || (typeKind == ast.TypeKindNonNull && p.v.Operation.TypeNameString(p.v.Operation.Types[typeRef].OfType) == typeString) {
181+
if isEnum || typeName == typeString || (typeKind == ast.TypeKindNonNull && p.v.Operation.TypeNameString(p.v.Operation.Types[typeRef].OfType) == typeString) {
172182
query[i].rawMessage = []byte(`"` + query[i].Value + `"`)
173183
} else {
174184
query[i].rawMessage = []byte(query[i].Value)

0 commit comments

Comments
 (0)