diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index fd55b4c8a4..4eaec9deaf 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -97,8 +97,8 @@ config :block_scout_web, BlockScoutWeb.CSPHeader, config :block_scout_web, Api.GraphQL, enabled: ConfigHelper.parse_bool_env_var("API_GRAPHQL_ENABLED", "true"), token_limit: ConfigHelper.parse_integer_env_var("API_GRAPHQL_TOKEN_LIMIT", 1000), - # Needs to be 200 to support the schema introspection for graphiql - max_complexity: ConfigHelper.parse_integer_env_var("API_GRAPHQL_MAX_COMPLEXITY", 200) + # Needs to be 215 to support the schema introspection for graphiql + max_complexity: ConfigHelper.parse_integer_env_var("API_GRAPHQL_MAX_COMPLEXITY", 215) # Configures Ueberauth local settings config :ueberauth, Ueberauth, diff --git a/apps/block_scout_web/test/block_scout_web/graphql/schema/query/address_test.exs b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/address_test.exs index 4371c4f038..3b0c3fec22 100644 --- a/apps/block_scout_web/test/block_scout_web/graphql/schema/query/address_test.exs +++ b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/address_test.exs @@ -407,7 +407,9 @@ defmodule BlockScoutWeb.GraphQL.Schema.Query.AddressTest do variables = %{ "hash" => to_string(address.hash), - "first" => 67 + # Add +5 because of the increase in complexity limit. For more info, see + # https://github.com/blockscout/blockscout/pull/9630 + "first" => 67 + 5 } conn = post(conn, "/api/v1/graphql", query: query, variables: variables) diff --git a/apps/block_scout_web/test/block_scout_web/graphql/schema/query/addresses_test.exs b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/addresses_test.exs index 2199b4a28c..32bbc5fdd2 100644 --- a/apps/block_scout_web/test/block_scout_web/graphql/schema/query/addresses_test.exs +++ b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/addresses_test.exs @@ -157,10 +157,10 @@ defmodule BlockScoutWeb.GraphQL.Schema.Query.AddressesTest do end test "correlates complexity to size of 'hashes' argument", %{conn: conn} do - # max of 50 addresses with four fields of complexity 1 can be fetched - # per query: - # 50 * 4 = 200, which is equal to a max complexity of 200 - hashes = 51 |> build_list(:address) |> Enum.map(&to_string(&1.hash)) + # max of 53 addresses with four fields of complexity 1 can be fetched per + # query: 53 * 4 = 212, which is the upper bound before reaching the max + # complexity limit of 215 + hashes = 54 |> build_list(:address) |> Enum.map(&to_string(&1.hash)) query = """ query ($hashes: [AddressHash!]!) { diff --git a/apps/block_scout_web/test/block_scout_web/graphql/schema/query/introspection_test.exs b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/introspection_test.exs new file mode 100644 index 0000000000..cdc7b8e318 --- /dev/null +++ b/apps/block_scout_web/test/block_scout_web/graphql/schema/query/introspection_test.exs @@ -0,0 +1,120 @@ +defmodule BlockScoutWeb.Schema.Query.IntrospectionTest do + use BlockScoutWeb.ConnCase + + test "fetches schema", %{conn: conn} do + introspection_query = ~S""" + query IntrospectionQuery { + __schema { + queryType { + name + } + mutationType { + name + } + + types { + ...FullType + } + directives { + name + description + + locations + args { + ...InputValue + } + } + } + } + + fragment FullType on __Type { + kind + name + description + + fields(includeDeprecated: true) { + name + description + args { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + description + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + + fragment InputValue on __InputValue { + name + description + type { + ...TypeRef + } + defaultValue + } + + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + } + } + """ + + conn = get(conn, "/api/v1/graphql", query: introspection_query) + response = json_response(conn, 200) + + assert %{"data" => %{"__schema" => %{"directives" => _}}} = response + end +end diff --git a/config/runtime.exs b/config/runtime.exs index 9bee8b15ae..6013dd4b8f 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -115,8 +115,8 @@ config :block_scout_web, Api.GraphQL, ), enabled: ConfigHelper.parse_bool_env_var("API_GRAPHQL_ENABLED", "true"), token_limit: ConfigHelper.parse_integer_env_var("API_GRAPHQL_TOKEN_LIMIT", 1000), - # Needs to be 200 to support the schema introspection for graphiql - max_complexity: ConfigHelper.parse_integer_env_var("API_GRAPHQL_MAX_COMPLEXITY", 200) + # Needs to be 215 to support the schema introspection for graphiql + max_complexity: ConfigHelper.parse_integer_env_var("API_GRAPHQL_MAX_COMPLEXITY", 215) # Configures History price_chart_config =