From 87ae5fdef4dc978352608840fac28540cdc1e1a1 Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Wed, 19 Jan 2022 10:55:53 +0100 Subject: [PATCH 1/3] Update changelog --- CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c460125641..3d3bb82696 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,14 @@ ## 1.6.7 -- Bug Fix: [Fix check unknown types to also cover wrapped types](https://github.com/absinthe-graphql/absinthe/pull/1138) +- Feature: [Add GraphQL document formatter](https://github.com/absinthe-graphql/absinthe/pull/1114) +- Bug Fix: [Fix Phase.Schema.Validation.InputOutputTypesCorrectlyPlaced not applied to SDL schema's](https://github.com/absinthe-graphql/absinthe/pull/1142/files) +- Bug Fix: [Use inspect/1 to safely encode bad binary samples](https://github.com/absinthe-graphql/absinthe/pull/1121) +- Bug Fix: [key :is_type_of not found on Interface ](https://github.com/absinthe-graphql/absinthe/issues/1077) +- Bug Fix: [Validate object/interfaces implement all transitive interfaces](https://github.com/absinthe-graphql/absinthe/pull/1127) +- Bug Fix: [Fix check unknown types to also cover wrapped types](https://github.com/absinthe-graphql/absinthe/pull/1138) This could break incoming documents previously considered valid. Skip the `Absinthe.Phase.Validation.KnownTypeNames` phase to avoid this check. See `Absinthe.Pipeline` on adjusting the document pipeline. - Bug Fix: [Validate field names are unique to an object, interface or an input object](https://github.com/absinthe-graphql/absinthe/pull/1135) -- Bug Fix: [Validate variable usage in according to spec](https://github.com/absinthe-graphql/absinthe/pull/1141) +- Bug Fix: [Validate variable usage in according to spec](https://github.com/absinthe-graphql/absinthe/pull/1141). This could break incoming documents previously considered valid. Skip the `Absinthe.Phase.Document.Arguments.VariableTypesMatch` phase to avoid this check. See `Absinthe.Pipeline` on adjusting the document pipeline. ## 1.6.6 From e91a70905cf5a68281ce1df109a0a1d7a4fef68f Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Wed, 19 Jan 2022 10:56:29 +0100 Subject: [PATCH 2/3] Update docs --- lib/absinthe/adapter/language_conventions.ex | 2 +- lib/absinthe/blueprint/execution.ex | 2 +- lib/absinthe/formatter.ex | 24 ++++++++++--------- lib/absinthe/middleware.ex | 2 +- .../arguments/variable_types_match.ex | 2 ++ .../validation/utils/message_suggestions.ex | 1 + lib/absinthe/phase/document/variables.ex | 2 +- lib/absinthe/pipeline.ex | 12 ++++++++++ lib/absinthe/resolution.ex | 6 ++--- lib/absinthe/schema.ex | 4 ++-- lib/absinthe/type/object.ex | 2 +- mix.exs | 9 ++++--- 12 files changed, 44 insertions(+), 24 deletions(-) diff --git a/lib/absinthe/adapter/language_conventions.ex b/lib/absinthe/adapter/language_conventions.ex index 474ef1f242..cac3811986 100644 --- a/lib/absinthe/adapter/language_conventions.ex +++ b/lib/absinthe/adapter/language_conventions.ex @@ -10,7 +10,7 @@ defmodule Absinthe.Adapter.LanguageConventions do For example, this document: - ``` + ```graphql { myUser: createUser(userId: 2) { firstName diff --git a/lib/absinthe/blueprint/execution.ex b/lib/absinthe/blueprint/execution.ex index afaebc87ab..3152506c11 100644 --- a/lib/absinthe/blueprint/execution.ex +++ b/lib/absinthe/blueprint/execution.ex @@ -6,7 +6,7 @@ defmodule Absinthe.Blueprint.Execution do drive a document's execution. Here's how the execution flow works. Given a document like: - ``` + ```graphql { posts { title diff --git a/lib/absinthe/formatter.ex b/lib/absinthe/formatter.ex index cbc662d40d..5b273638f4 100644 --- a/lib/absinthe/formatter.ex +++ b/lib/absinthe/formatter.ex @@ -5,22 +5,24 @@ defmodule Absinthe.Formatter do Will format files with the extensions .graphql or .gql ## Example - - Absinthe.Formatter.format("{ version }") - "{\n version\n}\n" + ```elixir + Absinthe.Formatter.format("{ version }") + "{\n version\n}\n" + ``` From Elixir 1.13 onwards the Absinthe.Formatter can be added to the formatter as a plugin: - # .formatter.exs - [ - # Define the desired plugins - plugins: [Absinthe.Formatter], - # Remember to update the inputs list to include the new extensions - inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}", "{lib, priv}/**/*.{gql,graphql}"] - ] - + ```elixir + # .formatter.exs + [ + # Define the desired plugins + plugins: [Absinthe.Formatter], + # Remember to update the inputs list to include the new extensions + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}", "{lib, priv}/**/*.{gql,graphql}"] + ] + ``` """ def features(_opts) do diff --git a/lib/absinthe/middleware.ex b/lib/absinthe/middleware.ex index fb9272cf4c..38c58b2e2d 100644 --- a/lib/absinthe/middleware.ex +++ b/lib/absinthe/middleware.ex @@ -138,7 +138,7 @@ defmodule Absinthe.Middleware do ``` Given a document like: - ``` + ```graphql { lookupUser { name }} ``` diff --git a/lib/absinthe/phase/document/arguments/variable_types_match.ex b/lib/absinthe/phase/document/arguments/variable_types_match.ex index 34de9a1452..efa838b485 100644 --- a/lib/absinthe/phase/document/arguments/variable_types_match.ex +++ b/lib/absinthe/phase/document/arguments/variable_types_match.ex @@ -1,4 +1,6 @@ defmodule Absinthe.Phase.Document.Arguments.VariableTypesMatch do + @moduledoc false + # Implements: 5.8.5. All Variable Usages are Allowed # Specifically, it implements "Variable usages must be compatible with the arguments they are passed to." # See relevant counter-example: https://spec.graphql.org/draft/#example-2028e diff --git a/lib/absinthe/phase/document/validation/utils/message_suggestions.ex b/lib/absinthe/phase/document/validation/utils/message_suggestions.ex index 37a113acdf..a605096b40 100644 --- a/lib/absinthe/phase/document/validation/utils/message_suggestions.ex +++ b/lib/absinthe/phase/document/validation/utils/message_suggestions.ex @@ -1,4 +1,5 @@ defmodule Absinthe.Phase.Document.Validation.Utils.MessageSuggestions do + @moduledoc false @suggest 5 @doc """ diff --git a/lib/absinthe/phase/document/variables.ex b/lib/absinthe/phase/document/variables.ex index 0a3a6fc0d1..538e1429a4 100644 --- a/lib/absinthe/phase/document/variables.ex +++ b/lib/absinthe/phase/document/variables.ex @@ -10,7 +10,7 @@ defmodule Absinthe.Phase.Document.Variables do # # Given a GraphQL document that looks like: # - # ``` + # ```graphql # query Item($id: ID!, $text = String = "Another") { # item(id: $id, category: "Things") { # name diff --git a/lib/absinthe/pipeline.ex b/lib/absinthe/pipeline.ex index 31bb263b75..3ee2079a89 100644 --- a/lib/absinthe/pipeline.ex +++ b/lib/absinthe/pipeline.ex @@ -4,6 +4,12 @@ defmodule Absinthe.Pipeline do A pipeline is merely a list of phases. This module contains functions for building, modifying, and executing pipelines of phases. + + Pipelines are used to build, validate and manipulate GraphQL documents or schema's. + + * See [`Absinthe.Plug`](https://hexdocs.pm/absinthe_plug/Absinthe.Plug.html) on adjusting the document pipeline for GraphQL over http requests. + * See [`Absinthe.Phoenix`](https://hexdocs.pm/absinthe_phoenix/) on adjusting the document pipeline for GraphQL over Phoenix channels. + * See `Absinthe.Schema` on adjusting the schema pipeline for schema manipulation. """ alias Absinthe.Phase @@ -38,6 +44,9 @@ defmodule Absinthe.Pipeline do @spec for_document(Absinthe.Schema.t()) :: t @spec for_document(Absinthe.Schema.t(), Keyword.t()) :: t + @doc """ + The default document pipeline + """ def for_document(schema, options \\ []) do options = options(Keyword.put(options, :schema, schema)) @@ -115,6 +124,9 @@ defmodule Absinthe.Pipeline do @spec for_schema(nil | Absinthe.Schema.t()) :: t @spec for_schema(nil | Absinthe.Schema.t(), Keyword.t()) :: t + @doc """ + The default schema pipeline + """ def for_schema(schema, options \\ []) do options = options diff --git a/lib/absinthe/resolution.ex b/lib/absinthe/resolution.ex index c7ab9e0c34..9808232d71 100644 --- a/lib/absinthe/resolution.ex +++ b/lib/absinthe/resolution.ex @@ -112,7 +112,7 @@ defmodule Absinthe.Resolution do ## Examples Given some query: - ``` + ```graphql {users { email }} ``` @@ -146,7 +146,7 @@ defmodule Absinthe.Resolution do ## Example Given a document like: - ``` + ```graphql { user { id name }} ``` @@ -162,7 +162,7 @@ defmodule Absinthe.Resolution do `child_fields` will be `["id", "name"]`. It correctly handles fragments, so for example if you had the document: - ``` + ```graphql { user { ... on User { diff --git a/lib/absinthe/schema.ex b/lib/absinthe/schema.ex index ce63b00b60..b13c321657 100644 --- a/lib/absinthe/schema.ex +++ b/lib/absinthe/schema.ex @@ -206,7 +206,7 @@ defmodule Absinthe.Schema do When you push a mutation, you can have selections on that mutation result to get back data you need, IE - ``` + ```graphql mutation { createUser(accountId: 1, name: "bob") { id @@ -218,7 +218,7 @@ defmodule Absinthe.Schema do However, what if you want to know when OTHER people create a new user, so that your UI can update as well. This is the point of subscriptions. - ``` + ```graphql subscription { newUsers { id diff --git a/lib/absinthe/type/object.ex b/lib/absinthe/type/object.ex index 45787c2570..f7595db742 100644 --- a/lib/absinthe/type/object.ex +++ b/lib/absinthe/type/object.ex @@ -31,7 +31,7 @@ defmodule Absinthe.Type.Object do Given we have a query that supports getting a person by name (see `Absinthe.Schema`), and a query document like the following: - ``` + ```graphql { person(name: "Joe") { name diff --git a/mix.exs b/mix.exs index 450edbf937..d59451ec6a 100644 --- a/mix.exs +++ b/mix.exs @@ -122,7 +122,8 @@ defmodule Absinthe.Mixfile do "guides/client/apollo.md", "guides/client/relay.md", "guides/upgrading/v1.4.md", - "guides/upgrading/v1.5.md" + "guides/upgrading/v1.5.md", + "CHANGELOG.md" ] end @@ -132,7 +133,8 @@ defmodule Absinthe.Mixfile do Tutorial: ~r/guides\/tutorial\/.*/, Topics: ~r/guides\/[^\/]+\.md/, "Client Guides": ~r/guides\/client\/.*/, - "Upgrade Guides": ~r/guides\/upgrading\/.*/ + "Upgrade Guides": ~r/guides\/upgrading\/.*/, + Changelog: "CHANGELOG.md" ] end @@ -176,7 +178,8 @@ defmodule Absinthe.Mixfile do Subscriptions: [ Absinthe.Subscription, Absinthe.Subscription.Pubsub, - Absinthe.Subscription.Local + Absinthe.Subscription.Local, + Absinthe.Subscription.PipelineSerializer ], Extensibility: [ Absinthe.Pipeline, From b22b027a9270273247a24996aa9b65b344994ead Mon Sep 17 00:00:00 2001 From: Maarten van Vliet Date: Wed, 19 Jan 2022 10:56:48 +0100 Subject: [PATCH 3/3] Update ex_doc --- mix.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mix.lock b/mix.lock index 911e319e00..22bedc2e56 100644 --- a/mix.lock +++ b/mix.lock @@ -4,15 +4,15 @@ "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_doc": {:hex, :ex_doc, "0.25.2", "4f1cae793c4d132e06674b282f1d9ea3bf409bcca027ddb2fe177c4eed6a253f", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "5b0c172e87ac27f14dfd152d52a145238ec71a95efbf29849550278c58a393d6"}, + "ex_doc": {:hex, :ex_doc, "0.27.3", "d09ed7ab590b71123959d9017f6715b54a448d76b43cf909eb0b2e5a78a977b2", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "ee60b329d08195039bfeb25231a208749be4f2274eae42ce38f9be0538a2f2e6"}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "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.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "makeup_graphql": {:hex, :makeup_graphql, "0.1.2", "81e2939aab6d2b81d39ee5d9e13fae02599e9ca6e1152e0eeed737a98a5f96aa", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "3390ab04ba388d52a94bbe64ef62aa4d7923ceaffac43ec948f58f631440e8fb"}, "mix_test_watch": {:hex, :mix_test_watch, "1.0.2", "34900184cbbbc6b6ed616ed3a8ea9b791f9fd2088419352a6d3200525637f785", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "47ac558d8b06f684773972c6d04fcc15590abdb97aeb7666da19fcbfdc441a07"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"}, "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, }