diff --git a/lib/dato_cms_graphql/graphql_base.rb b/lib/dato_cms_graphql/graphql_base.rb index 6691e87..44f9ef1 100644 --- a/lib/dato_cms_graphql/graphql_base.rb +++ b/lib/dato_cms_graphql/graphql_base.rb @@ -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} } diff --git a/lib/test_schema.rb b/lib/test_schema.rb index d792723..2771811 100644 --- a/lib/test_schema.rb +++ b/lib/test_schema.rb @@ -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