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

Not compatible with Rails 7.1 #460

Closed
svobom57 opened this issue Jan 30, 2024 · 3 comments · Fixed by #461
Closed

Not compatible with Rails 7.1 #460

svobom57 opened this issue Jan 30, 2024 · 3 comments · Fixed by #461

Comments

@svobom57
Copy link
Contributor

svobom57 commented Jan 30, 2024

Description

We recently tried migrating our app to Rails 7.1 and hit a road block with Graphiti. When I now try to spin up my Rails environment (with eager_load = true) I get errors similar to this:

vendor/bundle/ruby/3.2.0/gems/graphiti-1.3.9/lib/graphiti/util/serializer_relationships.rb:122:in
`validate_link_for_sideload!': UserResource: Cannot link to sideload :listings! (Graphiti::Errors::InvalidLink)

Make sure the endpoint "/api/selling/listings" exists with action :index, or customize the endpoint for Selling::ListingResource.

If you do not wish to generate a link, pass link: false or set self.autolink = false.

I managed to debug what the issue is:

This issue is due to this line of code in Graphiti:

unless prc.call(sideload.resource.endpoint[:full_path], action)

that now returns nil after Rails 7.1 upgrade. The Graphiti.config.context_for_endpoint is initialized here:
::Rails.application.routes.recognize_path(path, method: method)

So it seems like the above call is now not returning the route properly when a symbol route is passed into it anymore.

If I cast the sideload.resource.endpoint[:full_path] to a string it starts working again...

This is because:

::Rails.application.routes.recognize_path(:"/api/selling/listings", method: :get)
NoMethodError: undefined method `include?' for :"/api/selling/listings":Symbol
from /usr/local/bundle/gems/actionpack-7.1.1/lib/action_dispatch/routing/route_set.rb:887:in `recognize_path'

since the implementation of the Rails.application.routes.recognize_path changed in Rails 7.1.

@aravindaytha12
Copy link

aravindaytha12 commented Mar 13, 2024

Hi @svobom57 , @richmolj,

(1) This file changes not reflected after doing bundle install in my project and in gems path
gem 'graphiti'

(2) To get this change for my project I have used along with branch
gem 'graphiti', git: "https://github.com/graphiti-api/graphiti.git", branch: 'master'

(3) May I know what is the default branch while we use in Gemfile and Why this change not reflected

If this PR is closed, can please merge this master branch changes into the required branch
So, that without any branches I can direct use in my project path as
gem 'graphiti'

@jkeen
Copy link
Collaborator

jkeen commented Mar 17, 2024

@aravindaytha12 1.4.0 was just officially released, so option 1 should load that version which contains the fixes you need

@aravindaytha12
Copy link

@aravindaytha12 1.4.0 was just officially released, so option 1 should load that version which contains the fixes you need

Thanks @jkeen ..!

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

Successfully merging a pull request may close this issue.

3 participants