Skip to content

Commit

Permalink
Finally tests are working
Browse files Browse the repository at this point in the history
  • Loading branch information
netikular committed Jan 30, 2024
1 parent 65454e1 commit 612640b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/dato_cms_graphql/graphql_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse(query)

def query_for
parse <<~GRAPHQL
query($skip: Int) {
query($skip: IntType) {
items: all#{plural_name}(first: #{graphql_page_size}, skip: $skip) {
#{fields}
}
Expand Down
60 changes: 35 additions & 25 deletions lib/test_schema.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
## I'm stuck here making the mock - int type isn't defined on my schema ???

class PersonType < GraphQL::Schema::Object
field :id, String, null: true
field :name, String, null: true
end
class TestSchema < GraphQL::Schema
class IntTypeType < GraphQL::Schema::Scalar
def self.coerce_input(value, ctx)
value.to_i
end

class MetaType < GraphQL::Schema::Object
field :count, Int, null: false
end
def self.coerce_result(value, ctx)
value.to_i
end
end

class QueryType < GraphQL::Schema::Object
field :_all_under_tests_meta, MetaType, null: false
def _all_under_tests_meta
OpenStruct.new(
count: 10
)
class PersonType < GraphQL::Schema::Object
field :id, String, null: true
field :name, String, null: true
end

field :all_under_tests, PersonType, null: false do
argument :skip, Int, required: false
argument :first, Int, required: false
class MetaType < GraphQL::Schema::Object
field :count, IntTypeType, null: false
end

def all_under_tests
OpenStruct.new(
id: "test",
name: "Stan"
)
class QueryType < GraphQL::Schema::Object
field :int_type, IntTypeType, null: false

field :_all_under_tests_meta, MetaType, null: false
def _all_under_tests_meta
OpenStruct.new(
count: 10
)
end

field :all_under_tests, PersonType, null: false do
argument :skip, IntTypeType, required: false
argument :first, IntTypeType, required: false
end

def all_under_tests
OpenStruct.new(
id: "test",
name: "Stan"
)
end
end
end

class TestSchema < GraphQL::Schema
query(QueryType)
def self.resolve_type(_type, obj, _ctx)
obj.type
Expand Down

0 comments on commit 612640b

Please sign in to comment.