Hello @Olu and thanks for the quick reply.
In my setup I have a supergraph API (which is used as an entry point to all underlying APIs) and a single subgraph API.
Supergraph API:
{
"api_id": "ebf5ecc5-2bff-4700-aabf-28ddb08483b4",
"auth_configs": {
"authToken": {
"auth_header_name": "Authorization"
}
},
"enable_jwt": false,
"id": "ebf5ecc5-2bff-4700-aabf-28ddb08483b4",
"name": "GraphQL API",
"org_id": "",
"proxy": {
"listen_path": "/api/",
"strip_listen_path": true
},
"state": "active",
"use_basic_auth": false,
"use_keyless": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"use_extended_paths": true
}
}
},
"enable_coprocess_auth": false,
"graphql": {
"schema": "type Query {\n characters(filter: FilterCharacter, page: Int): Characters\n}\n\ninput FilterCharacter {\n name: String\n status: String\n species: String\n type: String\n gender: String! = \"M\"\n}\n\ntype Characters {\n info: Info\n results: [Character]\n}\n\ntype Info {\n count: Int\n next: Int\n pages: Int\n prev: Int\n}\n\ntype Character {\n gender: String\n id: ID\n name: String\n}",
"enabled": true,
"engine": {
"field_configs": [],
"data_sources": []
},
"type_field_configurations": [],
"execution_mode": "supergraph",
"proxy": {
"auth_headers": {}
},
"subgraph": {
"sdl": ""
},
"supergraph": {
"updated_at": "2022-03-11T16:08:13.774Z",
"subgraphs": [
{
"api_id": "sw",
"name": "SW API",
"url": "tyk://sw-api/",
"sdl": "type Query {\n characters(filter: FilterCharacter, page: Int): Characters\n}\n\ninput FilterCharacter {\n name: String\n status: String\n species: String\n type: String\n gender: String! = \"M\"\n}\n\ntype Characters {\n info: Info\n results: [Character]\n}\n\ntype Info {\n count: Int\n next: Int\n pages: Int\n prev: Int\n}\n\ntype Character {\n gender: String\n id: ID\n name: String\n}"
}
],
"merged_sdl": "type Query {\n characters(filter: FilterCharacter, page: Int): Characters\n}\n\ninput FilterCharacter {\n name: String\n status: String\n species: String\n type: String\n gender: String! = \"M\"\n}\n\ntype Characters {\n info: Info\n results: [Character]\n}\n\ntype Info {\n count: Int\n next: Int\n pages: Int\n prev: Int\n}\n\ntype Character {\n gender: String\n id: ID\n name: String\n}",
"global_headers": {}
},
"version": "2",
"playground": {
"enabled": true,
"path": "/playground"
},
"last_schema_update": "2022-03-11T16:08:13.774Z"
}
}
Please pay atttention to the following GraphQL input type with a required field with default value:
input FilterCharacter {
name: String
status: String
species: String
type: String
gender: String! = "M"
}
Subgraph API:
{
"api_id": "sw",
"auth_configs": {
"authToken": {
"auth_header_name": "Authorization"
}
},
"enable_jwt": false,
"id": "sw",
"name": "SW API",
"org_id": "",
"proxy": {
"listen_path": "/sw-api/",
"target_url": "https://rickandmortyapi.com/graphql",
"strip_listen_path": true
},
"state": "active",
"use_basic_auth": false,
"use_keyless": true,
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"use_extended_paths": true
}
}
},
"enable_coprocess_auth": false,
"slug": "sw-api",
"graphql": {
"schema": "type Query {\n characters(filter: FilterCharacter, page: Int): Characters\n}\n\ninput FilterCharacter {\n name: String\n status: String\n species: String\n type: String\n gender: String\n}\n\ntype Characters {\n info: Info\n results: [Character]\n}\n\ntype Info {\n count: Int\n next: Int\n pages: Int\n prev: Int\n}\n\ntype Character {\n gender: String\n id: ID\n name: String\n}",
"enabled": true,
"engine": {
"field_configs": [],
"data_sources": []
},
"type_field_configurations": [],
"execution_mode": "subgraph",
"proxy": {
"auth_headers": {}
},
"subgraph": {
"sdl": "type Query {\n characters(filter: FilterCharacter, page: Int): Characters\n}\n\ninput FilterCharacter {\n name: String\n status: String\n species: String\n type: String\n gender: String\n}\n\ntype Characters {\n info: Info\n results: [Character]\n}\n\ntype Info {\n count: Int\n next: Int\n pages: Int\n prev: Int\n}\n\ntype Character {\n gender: String\n id: ID\n name: String\n}"
},
"version": "2",
"playground": {
"enabled": true,
"path": ""
},
"last_schema_update": "2022-03-11T15:34:44.408Z"
},
"internal": true
}
tyk.conf
{
"listen_port": 8080,
"secret": "4c0a9fac-f06d-4032-8cb2-31c85a7c9705",
"template_path": "/opt/tyk-gateway/templates",
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"middleware_path": "/opt/tyk-gateway/middleware",
"use_db_app_configs": false,
"app_path": "/opt/tyk-gateway/apps/",
"storage": {
"type": "redis",
"host": "redis",
"port": 6379,
"username": "",
"password": "",
"database": 0,
"optimisation_max_idle": 2000,
"optimisation_max_active": 4000
},
"enable_analytics": false,
"analytics_config": {
"type": "csv",
"csv_dir": "/tmp",
"mongo_url": "",
"mongo_db_name": "",
"mongo_collection": "",
"purge_delay": -1,
"ignored_ips": []
},
"health_check": {
"enable_health_checks": false
},
"optimisations_use_async_session_write": true,
"enable_non_transactional_rate_limiter": true,
"enable_sentinel_rate_limiter": false,
"enable_redis_rolling_limiter": false,
"allow_master_keys": false,
"policies": {
"policy_source": "mongo",
"policy_path": "/opt/tyk-gateway/policies",
"policy_record_name1": "/opt/tyk-gateway/policies/policies.json"
},
"hash_keys": true,
"close_connections": false,
"http_server_options": {
"enable_websockets": true
},
"allow_insecure_configs": false,
"coprocess_options": {
"enable_coprocess": true,
"python_path_prefix": "/opt/tyk-gateway",
"coprocess_grpc_server": ""
},
"enable_bundle_downloader": true,
"bundle_base_url": "http://tyk-gateway-mw-bundles/",
"global_session_lifetime": 100,
"force_global_session_lifetime": false,
"max_idle_connections_per_host": 500,
"control_api_port": 8081
}
Sample request that works:
query ExampleQuery {
characters(
filter: {
gender: "M"
}
) {
results {
gender
name
}
}
}
Sample request that fails:
query ExampleQuery {
characters(
filter: {
}
) {
results {
gender
name
}
}
}
Snippet from Tyk logs with an error description:
time="Jun 02 11:34:16" level=debug msg="Started proxy"
time="Jun 02 11:34:16" level=debug msg="Stripping proxy listen path: /api/"
time="Jun 02 11:34:16" level=debug msg="Upstream path is: /"
time="Jun 02 11:34:16" level=debug msg=Started api_id=ebf5ecc5-2bff-4700-aabf-28ddb08483b4 api_name="GraphQL API" mw=ReverseProxy org_id= ts=1654169656876355179
time="Jun 02 11:34:16" level=debug msg="Upstream request URL: /" api_id=ebf5ecc5-2bff-4700-aabf-28ddb08483b4 api_name="GraphQL API" mw=ReverseProxy org_id=
time="Jun 02 11:34:16" level=debug msg="Outbound request URL: " api_id=ebf5ecc5-2bff-4700-aabf-28ddb08483b4 api_name="GraphQL API" mw=ReverseProxy org_id=
time="Jun 02 11:34:16" level=error msg="http: proxy error: could not render JSON variable, validation failed: /: {} "gender" value is required" api_id=ebf5ecc5-2bff-4700-aabf-28ddb08483b4 api_name="GraphQL API" mw=ReverseProxy org_id= prefix=proxy server_name= user_id=-- user_ip=127.0.0.1 user_name=
time="Jun 02 11:34:16" level=debug msg=Finished api_id=ebf5ecc5-2bff-4700-aabf-28ddb08483b4 api_name="GraphQL API" mw=ReverseProxy ns=319389 org_id=
time="Jun 02 11:34:16" level=debug msg="Upstream request took (ms): 0.327658"
time="Jun 02 11:34:16" level=debug msg="Done proxy"