From 909a9eff06b47f3575ff374810482f2565577e82 Mon Sep 17 00:00:00 2001 From: psguazz Date: Tue, 12 Mar 2024 12:19:59 +0100 Subject: [PATCH 1/3] Handling records without permalinks --- lib/dato_cms_graphql/rails/persistence.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dato_cms_graphql/rails/persistence.rb b/lib/dato_cms_graphql/rails/persistence.rb index ea7ce6c..228071f 100644 --- a/lib/dato_cms_graphql/rails/persistence.rb +++ b/lib/dato_cms_graphql/rails/persistence.rb @@ -7,7 +7,7 @@ def self.persist_record(query, record) ) .update( render: query.render?, - permalink: record.permalink, + permalink: (record.permalink if record.respond_to?(:permalink)), cms_record: record.localized_raw_attributes ) end From 17a22eac3046e1e35f89eeacbcc0b6eaf7dfa740 Mon Sep 17 00:00:00 2001 From: psguazz Date: Wed, 13 Mar 2024 09:56:34 +0100 Subject: [PATCH 2/3] Renaming BaseQuery --- lib/dato_cms_graphql.rb | 5 ++--- lib/dato_cms_graphql/{graphql_base.rb => base_query.rb} | 8 ++++---- test/graphql_fields_test.rb | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) rename lib/dato_cms_graphql/{graphql_base.rb => base_query.rb} (96%) diff --git a/lib/dato_cms_graphql.rb b/lib/dato_cms_graphql.rb index 67fbc39..c39e8ac 100644 --- a/lib/dato_cms_graphql.rb +++ b/lib/dato_cms_graphql.rb @@ -9,7 +9,7 @@ require_relative "dato_cms_graphql/version" require_relative "dato_cms_graphql/fields" -require_relative "dato_cms_graphql/graphql_base" +require_relative "dato_cms_graphql/base_query" require_relative "dato_cms_graphql/rails" require_relative "dato_cms_graphql/rails/routing" require_relative "dato_cms_graphql/rails/persistence" @@ -23,7 +23,6 @@ class Error < StandardError; end if ENV["TEST"] == "true" Client = GraphQL::Client.new(schema: TestSchema, execute: TestSchema) elsif ENV["DATO_API_TOKEN"].present? - HTTP = GraphQL::Client::HTTP.new("https://graphql.datocms.com") do def headers(context) { @@ -55,7 +54,7 @@ def self.queries Dir[File.join(@path_to_queries, "*.rb")].sort.each { require(_1) } ObjectSpace.each_object(::Class) - .select { |klass| klass < DatoCmsGraphql::GraphqlBase } + .select { |klass| klass < DatoCmsGraphql::BaseQuery } .group_by(&:name).values.map { |values| values.max_by(&:object_id) } .flatten end diff --git a/lib/dato_cms_graphql/graphql_base.rb b/lib/dato_cms_graphql/base_query.rb similarity index 96% rename from lib/dato_cms_graphql/graphql_base.rb rename to lib/dato_cms_graphql/base_query.rb index 018d149..eb4cca0 100644 --- a/lib/dato_cms_graphql/graphql_base.rb +++ b/lib/dato_cms_graphql/base_query.rb @@ -1,11 +1,11 @@ require_relative "model_iterator" module DatoCmsGraphql - class GraphqlBase + class BaseQuery class_attribute :graphql_page_size class_attribute :fields class_attribute :graphql_single_instance - class_attribute :bridgetown_render + class_attribute :renderable class << self def page_size(value) @@ -17,7 +17,7 @@ def single_instance(value) end def render(value) - self.bridgetown_render = value + self.renderable = value end def graphql_fields(*args) @@ -117,7 +117,7 @@ def single_instance? end def render? - bridgetown_render || false + renderable || false end def route diff --git a/test/graphql_fields_test.rb b/test/graphql_fields_test.rb index a46dbda..2f44ac6 100644 --- a/test/graphql_fields_test.rb +++ b/test/graphql_fields_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class UnderTest < DatoCmsGraphql::GraphqlBase +class UnderTest < DatoCmsGraphql::BaseQuery graphql_fields( :id ) From 5955bc85426ee876edfce981b2d61a045c055dd9 Mon Sep 17 00:00:00 2001 From: psguazz Date: Wed, 13 Mar 2024 10:58:39 +0100 Subject: [PATCH 3/3] Fixing lock file --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 47e70c1..863ca4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - dato_cms_graphql (0.1.5) + dato_cms_graphql (0.2.2) activesupport (~> 7.1.3) graphql-client (~> 0.19.0)