Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [0.3.0] - 2026-01-13

- Update gem to support Rails 8 for improved compatibility
- Add documentation enhancements and usage examples in AGENTS.md
- Update tests and documentation for better coverage and onboarding
- Fix warnings in tests related to string handling and deprecations
- Bump supported Ruby versions for broader compatibility
- Require ostruct as a runtime dependency for Ruby 3.4+ stdlib compatibility
- Clear out unnecessary extra slashes in query paths

## [0.2.8] - 2025-12-17

- Add ostruct and logger as runtime dependencies for Ruby 3.4+ stdlib compatibility
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
dato_cms_graphql (0.2.8)
dato_cms_graphql (0.3.0)
activesupport (>= 7.1, < 9.0)
graphql-client (>= 0.24.0, < 1.0)
logger
Expand Down
26 changes: 20 additions & 6 deletions lib/dato_cms_graphql/rails/persistence.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
module DatoCmsGraphql::Rails
module Persistence
def self.persist_record(query, record)
Object.const_get(query.query_name)
.find_or_create_by(
locale: I18n.locale,
cms_id: record.id
return if record.id.nil?

cms_id = record.id
existing = Record.find_by(
type: query.query_name,
locale: I18n.locale,
cms_id: cms_id
)
if existing
existing.update(
render: query.render?,
permalink: (record.permalink if record.respond_to?(:permalink)),
cms_record: record.localized_raw_attributes
)
.update(
else
Record.create(
type: query.query_name,
locale: I18n.locale,
cms_id: cms_id,
render: query.render?,
permalink: (record.permalink if record.respond_to?(:permalink)),
cms_record: record.localized_raw_attributes
)
end
end

def self.cache_data
Expand All @@ -21,7 +35,7 @@ def self.cache_data
record = query.get
persist_record(query, record)
else
query.all.each do |record|
query.all.uniq { |r| r.id }.each do |record|
persist_record(query, record)
end
end
Expand Down
6 changes: 4 additions & 2 deletions lib/dato_cms_graphql/rails/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class Railtie < ::Rails::Railtie
load File.join(__dir__, "cache_task.rake")
end
initializer "dato_cms_graphql_railtie.configure_rails_initialization" do |app|
DatoCmsGraphql.path_to_queries = app.root.join("app", "queries")
puts DatoCmsGraphql.path_to_queries
unless ENV["TEST"] == "true"
DatoCmsGraphql.path_to_queries = app.root.join("app", "queries")
puts DatoCmsGraphql.path_to_queries
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dato_cms_graphql/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DatoCmsGraphql
VERSION = "0.2.8"
VERSION = "0.3.0"
end