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

@put directive doesn't work on master #73

Open
QuinnWilton opened this issue Jun 17, 2020 · 3 comments
Open

@put directive doesn't work on master #73

QuinnWilton opened this issue Jun 17, 2020 · 3 comments

Comments

@QuinnWilton
Copy link
Contributor

While trying to upgrade a project to use Absinthe 1.5, I ran into issues with the @put directive. When using :absinthe_controller to decorate controller actions with a GQL query that uses @put, my queries are now failing with the error "Unknown directive 'put'."

I replicated this on master with a failing test here: https://github.com/QuinnWilton/absinthe_phoenix/blob/quinn%2Fput-tests/test/absinthe/phoenix/controller_test.exs#L132

@QuinnWilton
Copy link
Contributor Author

QuinnWilton commented Jun 17, 2020

I've managed to work around this issue in my project by adding the following to my schema:

  directive :put do
    on([:field, :fragment_spread, :inline_fragment])

    expand(fn
      _, node ->
        Absinthe.Blueprint.put_flag(node, :put, __MODULE__)
    end)
  end

@peaceful-james
Copy link

peaceful-james commented Jul 9, 2020

I see this as also happening with the @action directive. The action_mode enum is imported correctly though (if you try to redefine it in your schema then you get an error about it being declared twice).
Maybe import_types is having trouble importing directives?

Anyone else trying to workaround this, you can just copy the directive(s) you want directly from Absinthe.Phoenix.Types into your schema.ex. ATOW, it is this for @action:

  directive :action do
    on [:query, :mutation, :subscription]
    arg :mode, non_null(:action_mode)

    expand fn %{mode: mode}, node ->
      Absinthe.Blueprint.put_flag(node, {:action, mode}, __MODULE__)
    end
  end

@emisilvacab
Copy link

emisilvacab commented Jul 13, 2023

I had the same problem and it was resolved using
import_directives Absinthe.Phoenix.Types and
import_types Absinthe.Phoenix.Types, as you said import_types only imports the action_mode enum.

With this solution you don't have to add the code to your schema because the import works properly.

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