Skip to content

Commit

Permalink
Renaming BaseQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
psguazz committed Mar 13, 2024
1 parent 909a9ef commit 17a22ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
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 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 17a22ea

Please sign in to comment.