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

Rails 7.1 complains about improper logging call from graphql-client gem #88

Closed
erikdstock opened this issue Feb 2, 2024 · 6 comments
Closed

Comments

@erikdstock
Copy link
Collaborator

erikdstock commented Feb 2, 2024

As of Rails 7.1 a certain logging call triggered by Artemis through the graphql-client gem is supposed to use kwargs, but it doesn't. As a result, a wall of deprecation warnings appear in logs.

To make matters worse, the graphql-client source repo disappeared recently which is strange since it was repo under the github org. Here is one of the last wayback machine snapshots. As the remaining hosted documentation notes, this library is just a thin wrapper around the graphql gem, so it might be worth moving off this completely.

In our application we fixed this temporarily by adding a monkey patch to config/initializers/graphql_client.rb

require 'active_support/log_subscriber'

module GraphQL
  class Client
    class LogSubscriber < ActiveSupport::LogSubscriber
      def query(event)
        logger.info do
          name = event.payload[:operation_name].gsub('__', '::')
          type = event.payload[:operation_type].upcase
          # use keyword arg instead of positional for bolding
          color("#{name} #{type} (#{event.duration.round(1)}ms)", nil, bold: true)
        end

        logger.debug do
          event.payload[:document].to_query_string
        end
      end

      def error(event)
        logger.error do
          name = event.payload[:operation_name].gsub('__', '::')
          message = event.payload[:message]
          # use keyword arg instead of positional for bolding
          color("#{name} ERROR: #{message}", nil, bold: true)
        end
      end
    end
  end
end

Here is a link from our investigations with another approach to the fix.

h/t @jonallured for help with the investigation and fix.

@yuki24
Copy link
Owner

yuki24 commented Feb 5, 2024

@erikdstock Thanks for reporting! There seems to be some stuff that I have to catch up on in terms of the Ruby GraphQL client. I'll look into this and see if I can solve the issue quickly.

@yuki24
Copy link
Owner

yuki24 commented Feb 5, 2024

It seems like the repo has been moved to github-community-projects/graphql-client. I have sent a PR github-community-projects/graphql-client#10 as a pernanent fix for this.

I have also cut a new release of artemis v1.0.0 that does not have any version constrants on the graphcl gem, so you should be able to work around this issue by using the latest gems and the PR above:

gem "artemis", ">= 1.0.0"
gem "graphql-client", git: "https://github.com/github-community-projects/graphql-client.git", commit: "b177b19"

Edit 02/06/2024: The PR linked above has been merged and I have updated the gem declaration above.

@erikdstock
Copy link
Collaborator Author

It seems like the repo has been moved to github-community-projects/graphql-client.

Wow, how did you track this down?

@yuki24
Copy link
Owner

yuki24 commented Feb 8, 2024

There is a private Slack community for the people who purchased The Complete Guide to Rails Performance and a dozen of folks had a conversation about it.

@yuki24
Copy link
Owner

yuki24 commented Feb 20, 2024

@erikdstock I just wanted to check in and see if this is still an issue. Please let me know if you any other help. Thanks!

@yuki24
Copy link
Owner

yuki24 commented Apr 18, 2024

I'm closing this issue as I believe the deprecation warnings have been addressed in the new graphql-client repo.

@yuki24 yuki24 closed this as completed Apr 18, 2024
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