File tree Expand file tree Collapse file tree
pkg/engine/datasource/rest_datasource Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments