diff --git a/implementations/absinthe-federation/lib/products_web/schema.ex b/implementations/absinthe-federation/lib/products_web/schema.ex index d6468cd79..e5771285e 100644 --- a/implementations/absinthe-federation/lib/products_web/schema.ex +++ b/implementations/absinthe-federation/lib/products_web/schema.ex @@ -10,9 +10,27 @@ defmodule ProductsWeb.Schema do defstruct [:email, :name, :total_products_created] end + import_sdl """ + schema @link(url: "https://specs.apollo.dev/federation/v2.0", + import: [ + "@key", + "@shareable", + "@provides", + "@external", + "@tag", + "@extends", + "@override", + "@inaccessible" + ]) { + query: Query + mutation: Mutation + } + """ + @desc """ extend type User @key(fields: "email") { email: ID! @external + name: String @shareable @override(from: "users") totalProductsCreated: Int @external } """ @@ -24,6 +42,11 @@ defmodule ProductsWeb.Schema do external() end + field(:name, :string) do + shareable() + override_from("users") + end + field :total_products_created, :integer do external() end @@ -34,14 +57,19 @@ defmodule ProductsWeb.Schema do end @desc """ - type ProductDimension { + type ProductDimension @shareable { size: String weight: Float + unit: String @inaccessible } """ object :product_dimension do + shareable() field(:size, :string) field(:weight, :float) + field(:unit, :string) do + inaccessible() + end end @desc """ @@ -61,6 +89,7 @@ defmodule ProductsWeb.Schema do variation: ProductVariation dimensions: ProductDimension createdBy: User @provides(fields: "totalProductsCreated") + notes: String @tag(name: "internal") } """ object :product do @@ -79,6 +108,10 @@ defmodule ProductsWeb.Schema do resolve(&resolve_product_created_by/3) end + field(:notes, :string) do + tag("internal") + end + field :_resolve_reference, :product do resolve(&resolve_product_reference/2) end @@ -107,7 +140,7 @@ defmodule ProductsWeb.Schema do end defp resolve_product_dimensions(_product, _, _ctx) do - {:ok, %{size: "small", weight: 1}} + {:ok, %{size: "small", weight: 1, unit: "kg"}} end defp resolve_product_reference(%{id: id}, _ctx) do @@ -146,7 +179,7 @@ defmodule ProductsWeb.Schema do do: [ %User{ email: "support@apollographql.com", - name: "Apollo Studio Support", + name: "Jane Smith", total_products_created: 1337 } ] diff --git a/implementations/absinthe-federation/mix.exs b/implementations/absinthe-federation/mix.exs index 1929203f4..9e49150a8 100644 --- a/implementations/absinthe-federation/mix.exs +++ b/implementations/absinthe-federation/mix.exs @@ -35,7 +35,7 @@ defmodule Products.MixProject do defp deps do [ {:absinthe, "~> 1.7.0"}, - {:absinthe_federation, "~> 0.2.51"}, + {:absinthe_federation, "~> 0.2.52"}, {:absinthe_plug, "~> 1.5"}, {:phoenix, "~> 1.6.10"}, {:gettext, "~> 0.19"}, diff --git a/implementations/absinthe-federation/mix.lock b/implementations/absinthe-federation/mix.lock index 651ffbf62..0842fb2f0 100644 --- a/implementations/absinthe-federation/mix.lock +++ b/implementations/absinthe-federation/mix.lock @@ -1,6 +1,6 @@ %{ "absinthe": {:hex, :absinthe, "1.7.0", "36819e7b1fd5046c9c734f27fe7e564aed3bda59f0354c37cd2df88fd32dd014", [: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, "~> 1.0 or ~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "566a5b5519afc9b29c4d367f0c6768162de3ec03e9bf9916f9dc2bcbe7c09643"}, - "absinthe_federation": {:hex, :absinthe_federation, "0.2.51", "3d852204807ec1818934fbcfb21339ae67977614fb093b11fea98aafec7b94c6", [:mix], [{:absinthe, "~> 1.6.5 or ~> 1.7.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:dataloader, "~> 1.0.9", [hex: :dataloader, repo: "hexpm", optional: false]}], "hexpm", "ce191b336af060000060c22b460a4a76870b76de070de61cd5fc476136353c4a"}, + "absinthe_federation": {:hex, :absinthe_federation, "0.2.52", "22f6d62d0d301a253155716972e5787fd4e7f3cf3d614dfb6278118132c9a03d", [:mix], [{:absinthe, "~> 1.6.5 or ~> 1.7.0", [hex: :absinthe, repo: "hexpm", optional: false]}, {:dataloader, "~> 1.0.9", [hex: :dataloader, repo: "hexpm", optional: false]}], "hexpm", "f3e685e8c918641e14a881e5b0a5c17b93b6acd974a7c18e6363a476492126b3"}, "absinthe_plug": {:hex, :absinthe_plug, "1.5.8", "38d230641ba9dca8f72f1fed2dfc8abd53b3907d1996363da32434ab6ee5d6ab", [:mix], [{:absinthe, "~> 1.5", [hex: :absinthe, repo: "hexpm", optional: false]}, {:plug, "~> 1.4", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bbb04176647b735828861e7b2705465e53e2cf54ccf5a73ddd1ebd855f996e5a"}, "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},