Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meta shortcut syntax does not work for field #927

Closed
gabrielpra1 opened this issue May 20, 2020 · 2 comments
Closed

Meta shortcut syntax does not work for field #927

gabrielpra1 opened this issue May 20, 2020 · 2 comments

Comments

@gabrielpra1
Copy link

Environment

  • Elixir version (elixir -v): 1.10.2
  • Absinthe version (mix deps | grep absinthe): 1.5.1
  • Client Framework and version (Relay, Apollo, etc): Not relevant

Expected behavior

The following syntax was working in 1.4.16, however after updating to 1.5.1, it no longer works:

object :user do
  field :name, :string
  field :is_email_public, :boolean

  field :phone, :string, meta: [private: true]
  field :email, :string, meta: [private: & !&1.is_email_public]
  field :always_private, :string, meta: [private: true, rule: :private]
end

Error

== Compilation error in file test/middlewares/field_authorization_test.exs ==
** (KeyError) key :meta not found in: %Absinthe.Blueprint.Schema.FieldDefinition{__private__: [], __reference__: %{location: %{file: "/Users/gabrielpra/Projects/rajska/test/middlewares/field_authorization_test.exs", line: 80}, module: Rajska.FieldAuthorizationTest.Schema}, arguments: [], complexity: nil, config: nil, default_value: nil, deprecation: nil, description: nil, directives: [], errors: [], flags: %{}, function_ref: nil, identifier: :phone, middleware: [], module: Rajska.FieldAuthorizationTest.Schema, name: "phone", source_location: nil, triggers: [], type: :string}
    (stdlib 3.11.2) :maps.update(:meta, [private: true], %Absinthe.Blueprint.Schema.FieldDefinition{__private__: [], __reference__: %{location: %{file: "/Users/gabrielpra/Projects/rajska/test/middlewares/field_authorization_test.exs", line: 80}, module: Rajska.FieldAuthorizationTest.Schema}, arguments: [], complexity: nil, config: nil, default_value: nil, deprecation: nil, description: nil, directives: [], errors: [], flags: %{}, function_ref: nil, identifier: :phone, middleware: [], module: Rajska.FieldAuthorizationTest.Schema, name: "phone", source_location: nil, triggers: [], type: :string})
    (absinthe 1.5.1) lib/absinthe/blueprint/schema/field_definition.ex:7: anonymous fn/2 in Absinthe.Blueprint.Schema.FieldDefinition.__struct__/1
    (elixir 1.10.2) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (absinthe 1.5.1) lib/absinthe/blueprint/schema/field_definition.ex:7: Absinthe.Blueprint.Schema.FieldDefinition.__struct__/1
    (elixir 1.10.2) lib/kernel.ex:2168: Kernel.struct!/2
    (absinthe 1.5.1) lib/absinthe/schema/notation.ex:1508: Absinthe.Schema.Notation.scoped_def/5
    (absinthe 1.5.1) expanding macro: Absinthe.Schema.Notation.field/3
    test/middlewares/field_authorization_test.exs:80: Rajska.FieldAuthorizationTest.Schema (module)
    (absinthe 1.5.1) expanding macro: Absinthe.Schema.Notation.object/2
    test/middlewares/field_authorization_test.exs:74: Rajska.FieldAuthorizationTest.Schema (module)
    (elixir 1.10.2) lib/kernel/parallel_compiler.ex:396: Kernel.ParallelCompiler.require_file/2
    (elixir 1.10.2) lib/kernel/parallel_compiler.ex:306: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Using the meta/1 syntax still compiles, though:

object :user do
  field :name, :string
  field :is_email_public, :boolean

  field :phone, :string do
    meta([private: true])
  end
  field :email, :string do
    meta([private: & !&1.is_email_public])
  end
  field :always_private, :string do
    meta([private: true, rule: :private])
  end
end
@moperacz
Copy link

moperacz commented Jun 8, 2020

any news about this?

@tlvenn
Copy link
Member

tlvenn commented Sep 30, 2020

Fixed with #973

@tlvenn tlvenn closed this as completed Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants