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

Allowed arbitrary type definition when passing vars in testing #555

Closed
lobo-tuerto opened this issue May 28, 2018 · 2 comments
Closed

Allowed arbitrary type definition when passing vars in testing #555

lobo-tuerto opened this issue May 28, 2018 · 2 comments
Assignees
Milestone

Comments

@lobo-tuerto
Copy link

Environment

  • Elixir version (elixir -v): 1.6.4
  • Absinthe version (mix deps | grep absinthe): 1.4.12
  • Testing Framework: ExUnit

Expected behavior

I expected to see an error complaining about the incorrect type being supplied.

Actual behavior

The following piece of code is running without problems:

@query """
query ($filter: Boolean) {
  users(filter: $filter) {
    email
  }
}
"""
@variables %{filter: %{email: "admin"}}
test "users field returns a list of users filtered by email, using a variable" do
  conn = post(build_conn(), "/api", query: @query, variables: @variables)

  assert json_response(conn, 200) == %{
           "data" => %{
             "users" => [
               %{"email" => "admin@email.com"}
             ]
           }
         }
end

Note that:

query ($filter: Boolean) {

Should be:

query ($filter: UserFilter) {

It seems to be working with whatever type you pass to it, as long as the type exists.
If the type doesn't exist it complains accordingly.

Relevant Schema/Middleware Code

input_object :user_filter do
  field(:name, :string)
  field(:email, :string)
  field(:is_active, :boolean)
  field(:type, :user_type)
end

field :users, list_of(:user) do
  arg(:filter, :user_filter)
  # ...
@lobo-tuerto
Copy link
Author

Just tried it out in GraphiQL and it also works without problems.

Although I get a red line that indicates there is a problem with the type, but the query succeeds nonetheless.

screenshot-2018-5-28 graphiql

@benwilson512
Copy link
Contributor

Not entirely sure when this was fixed, but I just added a test case to master showing that this issue seems to be fixed. 392426b

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

2 participants