Skip to content

Commit

Permalink
Merge pull request #2 from Paradem/tweaks
Browse files Browse the repository at this point in the history
Tweaks
  • Loading branch information
psguazz authored Mar 13, 2024
2 parents 8ca65cd + 5955bc8 commit e55f3c6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
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.1.5)
dato_cms_graphql (0.2.2)
activesupport (~> 7.1.3)
graphql-client (~> 0.19.0)

Expand Down
5 changes: 2 additions & 3 deletions lib/dato_cms_graphql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -17,7 +17,7 @@ def single_instance(value)
end

def render(value)
self.bridgetown_render = value
self.renderable = value
end

def graphql_fields(*args)
Expand Down Expand Up @@ -117,7 +117,7 @@ def single_instance?
end

def render?
bridgetown_render || false
renderable || false
end

def route
Expand Down
2 changes: 1 addition & 1 deletion lib/dato_cms_graphql/rails/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/graphql_fields_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "test_helper"

class UnderTest < DatoCmsGraphql::GraphqlBase
class UnderTest < DatoCmsGraphql::BaseQuery
graphql_fields(
:id
)
Expand Down

0 comments on commit e55f3c6

Please sign in to comment.