rmosolgo / graphiql-rails

Mount the GraphiQL query editor in a Rails app
MIT License
447 stars 135 forks source link

Current GraphiQL version not compatible with graphql-ruby 1.9.x #67

Closed the-codetrane closed 3 years ago

the-codetrane commented 5 years ago

I have been trying to use this version of graphiql-rails with graphql version 1.9.3, which gave me the below response. When I ported back to 1.18.0, the proper response came through. I apologize that I can't make a PR myself to resolve this at the moment, since I'm a total n00b to GraphQL, but I wanted to make you aware for your next release.

Big fan of the tool, so thank you for the work y'all have done!

Michael

Mutation Type

class Types::MutationType < GraphQL::Schema::Object
  field :updateUser, mutation: Mutations::UpdateUser
end

Mutation

class Mutations::UpdateUser < Mutations::BaseMutation

  argument :id, ID, required: true
  argument :name, String, required: false
  argument :title, String, required: false
  argument :role, Int, required: false

  field :user, Types::UserType, null: true
  field :errors, [String], null: false

  def resolve( id:, name:, title:, role:)
    user = User.find(id)
    if user.update(name: name, title: title, role: role)
      {
        user: user,
        errors: []
      }
    else
      {
        user: nil,
        errors: []
      }
    end
  end
end

GraphQL mutation

mutation updateUser($id: ID!, $name: String, $title: String, $role: Int) {
  updateUser(id:$id, name: $name, title: $title, role:$role) {
    user {
      name
      id
    }
  }
}

// Query Values

{
  "id": 1,
  "name": "Mr. Smith",
  "title": "President",
  "role": 3
}

Return value

{
  "data": {
    "updateUser": {
      null
    }
  }
}
the-codetrane commented 5 years ago

It would appear that these breaking changes are what's causing the issue:

1.8.7 (9 Aug 2018)

Breaking changes

Bug fixes

New features

ACPK commented 5 years ago

@the-codetrane - This gem doesn't unless we downgrade to an older version of graphql (currently at v1.9.7)?

the-codetrane commented 5 years ago

@ACPK that would appear to be the case. These were the breaking changes I found that interfered with the gem. Now, this may have been resolved with v. 1.9.7. I was working with 1.9.3 at the time.

the-codetrane commented 3 years ago

Closed per new releases.