Skip to content

Commit

Permalink
Merge branch 'absinthe-graphql:main' into 1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov authored Mar 29, 2024
2 parents 050aac3 + 3a984cc commit 90a8188
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"lib/absinthe/plug/graphiql/assets.ex", :pattern_match_cov, 80}
]
50 changes: 37 additions & 13 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,37 @@ on:

jobs:
test:
name: Elixir ${{matrix.elixir}} / OTP ${{matrix.otp}}
runs-on: ubuntu-latest

runs-on: ubuntu-20.04
env:
MIX_ENV: test
strategy:
fail-fast: false
matrix:
elixir:
- '1.10'
- '1.11'
- "1.13"
- "1.14"
- "1.15"
otp:
- '22'
- '23'
- "24"
- "25"
- "26"
include:
- elixir: "1.15"
otp: "26"
format: true
exclude:
- elixir: "1.13"
otp: "26"
- elixir: "1.14"
otp: "26"

steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Elixir
uses: erlef/setup-elixir@v1
- uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- name: Restore deps cache
uses: actions/cache@v2
Expand All @@ -46,6 +56,7 @@ jobs:

- name: Check code format
run: mix format --check-formatted
if: ${{ matrix.format }}

- name: Compile dependencies
run: mix compile
Expand All @@ -54,3 +65,16 @@ jobs:

- name: Run unit tests
run: mix test

- name: Cache/uncache PLTs
uses: actions/cache@v3
with:
path: |
priv/plts
key: "${{ runner.os }}-\
erlang-${{ matrix.otp }}-\
elixir-${{ matrix.elixir }}-\
${{ hashFiles('mix.lock') }}"

- name: Run Dialyzer
run: mix dialyzer
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ erl_crash.dump
*.ez
.DS_Store
.tool-versions
.elixir_ls
.elixir_ls
priv/plts
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- Feature: Allow overriding `Absinthe.Plug.DocumentProvider.Compiled` process function.
- Feature: Opt out of the default [Transport Batch response nesting](https://github.com/absinthe-graphql/absinthe_plug/pull/237) with `transport_batch_payload_key: false`.
- Feature: [Add `Absinthe.Plug.assign_context/2` helper](https://github.com/absinthe-graphql/absinthe_plug/pull/230) for inserting values into a `conn`'s Absinthe context.
- Ensure all Absinthe.Plug options are overrideable via the runtime `put_options` function.
- Ensure all Absinthe.Plug options are overridable via the runtime `put_options` function.

## v1.5.0

Expand Down
4 changes: 2 additions & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is responsible for configuring your application
# and its dependencies with the aid of the Mix.Config module.
use Mix.Config
import Config

# This configuration is loaded before any dependency and is restricted
# to this project. If another project depends on this project, this
Expand All @@ -18,7 +18,7 @@ use Mix.Config
#
# Or configure a 3rd-party app:
#
config :logger, level: :warn
config :logger, level: :warning
#

# It is also possible to import configuration files, relative to this
Expand Down
8 changes: 6 additions & 2 deletions lib/absinthe/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ defmodule Absinthe.Plug do
:pubsub,
:analyze_complexity,
:max_complexity,
:token_limit,
:transport_batch_payload_key
]
@raw_options [
:analyze_complexity,
:max_complexity
:max_complexity,
:token_limit
]

@type function_name :: atom
Expand All @@ -154,7 +156,7 @@ defmodule Absinthe.Plug do
- `:no_query_message` -- (Optional) Message to return to the client if no query is provided (default: "No query document supplied").
- `:json_codec` -- (Optional) A `module` or `{module, Keyword.t}` dictating which JSON codec should be used (default: `Jason`). The codec module should implement `encode!/2` (e.g., `module.encode!(body, opts)`).
- `:pipeline` -- (Optional) `{module, atom}` reference to a 2-arity function that will be called to generate the processing pipeline. (default: `{Absinthe.Plug, :default_pipeline}`).
- `:document_providers` -- (Optional) A `{module, atom}` reference to a 1-arity function that will be called to determine the document providers that will be used to process the request. (default: `{Absinthe.Plug, :default_document_providers}`, which configures `Absinthe.Plug.DocumentProvider.Default` as the lone document provider). A simple list of document providers can also be given. See `Absinthe.Plug.DocumentProvider` for more information about document providers, their role in procesing requests, and how you can define and configure your own.
- `:document_providers` -- (Optional) A `{module, atom}` reference to a 1-arity function that will be called to determine the document providers that will be used to process the request. (default: `{Absinthe.Plug, :default_document_providers}`, which configures `Absinthe.Plug.DocumentProvider.Default` as the lone document provider). A simple list of document providers can also be given. See `Absinthe.Plug.DocumentProvider` for more information about document providers, their role in processing requests, and how you can define and configure your own.
- `:schema` -- (Required, if not handled by Mix.Config) The Absinthe schema to use. If a module name is not provided, `Application.get_env(:absinthe, :schema)` will be attempt to find one.
- `:serializer` -- (Optional) Similar to `:json_codec` but allows the use of serialization formats other than JSON, like MessagePack or Erlang Term Format. Defaults to whatever is set in `:json_codec`.
- `:content_type` -- (Optional) The content type of the response. Should probably be set if `:serializer` option is used. Defaults to `"application/json"`.
Expand All @@ -163,6 +165,7 @@ defmodule Absinthe.Plug do
- `:pubsub` -- (Optional) Pub Sub module for Subscriptions.
- `:analyze_complexity` -- (Optional) Set whether to calculate the complexity of incoming GraphQL queries.
- `:max_complexity` -- (Optional) Set the maximum allowed complexity of the GraphQL query. If a document’s calculated complexity exceeds the maximum, resolution will be skipped and an error will be returned in the result detailing the calculated and maximum complexities.
- `:token_limit` -- (Optional) Set a limit on the number of allowed parseable tokens in the GraphQL query. Queries with exceedingly high token counts can be expensive to parse. If a query's token count exceeds the set limit, an error will be returned during Absinthe parsing (default: `:infinity`).
- `:transport_batch_payload_key` -- (Optional) Set whether or not to nest Transport Batch request results in a `payload` key. Older clients expected this key to be present, but newer clients have dropped this pattern. (default: `true`)
"""
Expand All @@ -179,6 +182,7 @@ defmodule Absinthe.Plug do
| {module, atom},
analyze_complexity: boolean,
max_complexity: non_neg_integer | :infinity,
token_limit: non_neg_integer | :infinity,
serializer: module | {module, Keyword.t()},
content_type: String.t(),
before_send: {module, atom},
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/plug/batch/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ defmodule Absinthe.Plug.Batch.Runner do
{:ok, bp, _query, _index} -> bp
end)

querys_and_indices =
queries_and_indices =
Enum.map(valid_queries, fn
{:ok, _bp, query, index} -> {query, index}
end)

blueprints
|> Absinthe.Pipeline.BatchResolver.run(schema: schema)
|> Enum.zip(querys_and_indices)
|> Enum.zip(queries_and_indices)
|> Enum.map(fn {bp, {query, i}} ->
{i, build_result(bp, query)}
end)
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/plug/graphiql/assets.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
@moduledoc """
"""

@config Application.get_env(:absinthe_plug, Absinthe.Plug.GraphiQL)
@config Application.compile_env(:absinthe_plug, Absinthe.Plug.GraphiQL)
@default_config [
source: :smart,
local_url_path: "/absinthe_graphiql",
Expand Down Expand Up @@ -40,7 +40,7 @@ defmodule Absinthe.Plug.GraphiQL.Assets do
"graphiql.css",
{"graphiql.min.js", "graphiql.js"}
]},
{"graphiql-workspace", "1.1.4",
{"graphiql-workspace", "1.1.5",
[
"graphiql-workspace.css",
{"graphiql-workspace.min.js", "graphiql-workspace.js"}
Expand Down
4 changes: 1 addition & 3 deletions lib/absinthe/plug/graphiql/graphiql_playground.html.eex
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ add "&raw" to the end of the URL within a browser.
var options = {};
var protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
<%= if default_url do %>
options.endpoint = <%= default_url %>;
<% end %>
options.endpoint = <%= default_url %>;
<%= if socket_url do %>
options.subscriptionEndpoint = <%= socket_url %>;
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/plug/request/query.ex
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ defmodule Absinthe.Plug.Request.Query do
# DOCUMENT PROVIDERS
#

@spec calculate_document_providers(map) :: [Absinthe.Plug.DocumentProvider.t(), ...]
@spec calculate_document_providers(map) :: [Absinthe.Plug.DocumentProvider.t()]
defp calculate_document_providers(%{document_providers: {module, fun}} = config)
when is_atom(fun) do
apply(module, fun, [config])
Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/plug/types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Absinthe.Plug.Types do
localhost:4000/graphql
```
Note how there is a correspondance between the value of the `:users` argument
Note how there is a correspondence between the value of the `:users` argument
and the `-F` option indicating the associated file.
By treating uploads as regular arguments we get all the usual GraphQL argument
Expand Down
12 changes: 9 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ defmodule Absinthe.Plug.Mixfile do
package: package(),
source_url: "https://github.com/absinthe-graphql/absinthe_plug",
docs: [source_ref: "v#{@version}", main: "Absinthe.Plug"],
deps: deps()
deps: deps(),
dialyzer: [
plt_add_apps: [:mix],
plt_add_deps: :apps_direct,
plt_file: {:no_warn, "priv/plts/project.plt"}
]
]
end

Expand Down Expand Up @@ -42,10 +47,11 @@ defmodule Absinthe.Plug.Mixfile do

defp deps do
[
{:absinthe, "~> 1.5"},
{:absinthe, "~> 1.7"},
{:plug, "~> 1.4"},
{:jason, ">= 0.0.0", only: [:dev, :test]},
{:ex_doc, "~> 0.20", only: :dev}
{:ex_doc, "~> 0.20", only: :dev},
{:dialyxir, "~> 1.3", only: [:dev, :test], runtime: false}
]
end
end
14 changes: 8 additions & 6 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
%{
"absinthe": {:hex, :absinthe, "1.5.4", "e84820f770149ada718e2bd58939322965089a5badd9a0bfe632e05b27248dd0", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6df329a071865065edd13a5a1da9981dfe8dc22c5d6729218ca9023999e9a2ff"},
"absinthe": {:hex, :absinthe, "1.7.3", "128f9de8d8feab761a50483011c2652074de0a670316d0e24a4979daeb460c8f", [:mix], [{:dataloader, "~> 1.0.0", [hex: :dataloader, repo: "hexpm", optional: true]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 1.2.2 or ~> 1.3.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:opentelemetry_process_propagator, "~> 0.2.1", [hex: :opentelemetry_process_propagator, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "6def91514f023832dbb3433baa166366881648932211f2e8146f9792b08b7bb3"},
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
"earmark": {:hex, :earmark, "1.4.4", "4821b8d05cda507189d51f2caeef370cf1e18ca5d7dfb7d31e9cafe6688106a4", [:mix], [], "hexpm", "1f93aba7340574847c0f609da787f0d79efcab51b044bb6e242cae5aca9d264d"},
"earmark_parser": {:hex, :earmark_parser, "1.4.10", "6603d7a603b9c18d3d20db69921527f82ef09990885ed7525003c7fe7dc86c56", [:mix], [], "hexpm", "8e2d5370b732385db2c9b22215c3f59c84ac7dda7ed7e544d7c459496ae519c0"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.23.0", "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
"mime": {:hex, :mime, "1.4.0", "5066f14944b470286146047d2f73518cf5cca82f8e4815cf35d196b58cf07c47", [:mix], [], "hexpm", "75fa42c4228ea9a23f70f123c74ba7cece6a03b1fd474fe13f6a7a85c6ea4ff6"},
"nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
"plug": {:hex, :plug, "1.11.0", "f17217525597628298998bc3baed9f8ea1fa3f1160aa9871aee6df47a6e4d38e", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2d9c633f0499f9dc5c2fd069161af4e2e7756890b81adcbb2ceaa074e8308876"},
"plug_crypto": {:hex, :plug_crypto, "1.2.0", "1cb20793aa63a6c619dd18bb33d7a3aa94818e5fd39ad357051a67f26dfa2df6", [:mix], [], "hexpm", "a48b538ae8bf381ffac344520755f3007cc10bd8e90b240af98ea29b69683fc2"},
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"plug": {:hex, :plug, "1.14.2", "cff7d4ec45b4ae176a227acd94a7ab536d9b37b942c8e8fa6dfc0fff98ff4d80", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "842fc50187e13cf4ac3b253d47d9474ed6c296a8732752835ce4a86acdf68d13"},
"plug_crypto": {:hex, :plug_crypto, "1.2.5", "918772575e48e81e455818229bf719d4ab4181fcbf7f85b68a35620f78d89ced", [:mix], [], "hexpm", "26549a1d6345e2172eb1c233866756ae44a9609bd33ee6f99147ab3fd87fd842"},
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
}
2 changes: 1 addition & 1 deletion test/lib/absinthe/plug/transport_batching_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ defmodule Absinthe.Plug.TransportBatchingTest do
%{
id: "2",
query:
"query Upload($file: Upload) {uploadTest(fileA: $file)}",
"query Upload($file: Upload!) {uploadTest(fileA: $file)}",
variables: %{"file" => "a"}
}
]
Expand Down

0 comments on commit 90a8188

Please sign in to comment.