Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add features section to graphql proxy config #6298

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apidef/adapter/asyncapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ const expectedGraphqlConfig = `{
"global_headers": null
},
"proxy": {
"features": {
"use_immutable_headers": false
},
"auth_headers": {},
"request_headers": null,
"use_response_extensions": {
Expand Down
3 changes: 3 additions & 0 deletions apidef/adapter/openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ const expectedOpenAPIGraphQLConfig = `{
"global_headers": null
},
"proxy": {
"features": {
"use_immutable_headers": false
},
"auth_headers": {},
"request_headers": null,
"use_response_extensions": {
Expand Down
10 changes: 10 additions & 0 deletions apidef/api_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
"github.com/lonelycode/osin"

"github.com/TykTechnologies/storage/persistent/model"

"github.com/TykTechnologies/tyk/internal/event"

"github.com/TykTechnologies/tyk/internal/reflect"

"github.com/TykTechnologies/graphql-go-tools/pkg/execution/datasource"

"github.com/TykTechnologies/gojsonschema"

"github.com/TykTechnologies/tyk/regexp"

"github.com/TykTechnologies/tyk/internal/uuid"
Expand Down Expand Up @@ -847,13 +849,18 @@ type GraphQLResponseExtensions struct {
}

type GraphQLProxyConfig struct {
Features GraphQLProxyFeaturesConfig `bson:"features" json:"features"`
AuthHeaders map[string]string `bson:"auth_headers" json:"auth_headers"`
SubscriptionType SubscriptionType `bson:"subscription_type" json:"subscription_type,omitempty"`
RequestHeaders map[string]string `bson:"request_headers" json:"request_headers"`
UseResponseExtensions GraphQLResponseExtensions `bson:"use_response_extensions" json:"use_response_extensions"`
RequestHeadersRewrite map[string]RequestHeadersRewriteConfig `json:"request_headers_rewrite" bson:"request_headers_rewrite"`
}

type GraphQLProxyFeaturesConfig struct {
UseImmutableHeaders bool `bson:"use_immutable_headers" json:"use_immutable_headers"`
}

type RequestHeadersRewriteConfig struct {
Value string `json:"value" bson:"value"`
Remove bool `json:"remove" bson:"remove"`
Expand Down Expand Up @@ -1294,6 +1301,9 @@ func DummyAPI() APIDefinition {
Version: GraphQLConfigVersion2,
LastSchemaUpdate: nil,
Proxy: GraphQLProxyConfig{
Features: GraphQLProxyFeaturesConfig{
UseImmutableHeaders: true,
},
AuthHeaders: map[string]string{},
},
}
Expand Down
1 change: 1 addition & 0 deletions apidef/oas/oas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func TestOAS_ExtractTo_ResetAPIDefinition(t *testing.T) {
"APIDefinition.GraphQL.Engine.DataSources[0].Config[0]",
"APIDefinition.GraphQL.Engine.GlobalHeaders[0].Key",
"APIDefinition.GraphQL.Engine.GlobalHeaders[0].Value",
"APIDefinition.GraphQL.Proxy.Features.UseImmutableHeaders",
"APIDefinition.GraphQL.Proxy.AuthHeaders[0]",
"APIDefinition.GraphQL.Proxy.SubscriptionType",
"APIDefinition.GraphQL.Proxy.RequestHeaders[0]",
Expand Down
8 changes: 8 additions & 0 deletions apidef/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,14 @@ const Schema = `{
"proxy": {
"type": ["object", "null"],
"properties": {
"features": {
"type": ["object", "null"],
"properties": {
"use_immutable_headers": {
"type": "boolean"
}
}
},
"auth_headers": {
"type": ["object", "null"]
},
Expand Down
Loading