GraphQL introspection query returns wrong data

tyk-gateway OSS v4.1.0-rc10.

I’m using Tyk in GraphQL supergraph-subgraphs setting. I’m trying to query an introspection info:

query SampleIntrospectionQuery {
    __type(name: "Character") {
        name
    }
}

An expected response is:

{
    "data": {
        "__type": {
            "name": "Character"
        }
    }
}

But the whole GraphQL schema is returned instead:

{
    "data": {
        "__schema": {
            "queryType": {
                "name": "Query"
            },
            # skipped

I found out that I can make Tyk to return the requested introspection info only. I just need to add some other field to my query. An example:

query SampleIntrospectionQuery {
    __type(name: "Character") {
        name
    }
    characters { # I don't actually need this field
        results {
            gender
            name
        }
    }
}

With the query above Tyk returns an expected response (not mentioning the useless characters field).

Here is my setting:

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"
  }

}

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
}

@Andrey_Nado are you sending the SampleIntrospectionQuery to your subgraph or the supergraph?

I’m sending the query to the supergraph.

@Andrey_Nado I’ve spoken to our dev team and their assessment is that what you found is a defect that needs to be fixed.
I’ll create this in our Github issues section so you can track the progress there [TT-5766] GraphQL introspection query returns wrong data · Issue #4138 · TykTechnologies/tyk · GitHub

1 Like

@agata-wit thank you. Hope it’ll be fixed soon.

Hello @agata-wit!

I just checked recently released Tyk Gateway v4.1.0, the issue still remains.