1

I'm in the process of writing Rspec tests for my GraphQL endpoints, and I noticed that the objects they use are of the type Schema::Object. I have been using ObjectType for my objects, which means I can't use MySchema.execute() to test.

I've been trying to figure out the difference between the two types and can't find anything. That makes me think that I just have a fundamental misunderstanding of what's going on? Can someone explain this to me?

jkost4
  • 73
  • 1
  • 8
  • Can you give an example of a test that doesn’t work? I suspect `GraphQL::Schema::Object` is part of the new graphql-ruby 1.8 API, but that shouldn’t affect the top-level `schema.execute()` interface. – David Maze Dec 07 '18 at 14:42

1 Answers1

1

Take a look at this documentation: https://github.com/rmosolgo/graphql-ruby/blob/master/guides/schema/testing.md

Check out the section titled Don't test the schema.

The easiest way to test behavior of a GraphQL schema is to extract behavior into separate objects and test those objects in isolation. For Rails, you don't test your models by running controller tests, right? Similarly, you can test "lower-level" parts of the system on their own without running end-to-end tests.

It's hard to tell without code, but it seems like you're trying to test your GraphQL endpoint the hard way.

Ecnalyr
  • 5,792
  • 5
  • 43
  • 89