-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spec: a BrokenSchema presents easy-to-read errors instead of NoMethod…
…Error on nil
- Loading branch information
1 parent
02b8b86
commit 54a0f2f
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'ostruct' | ||
|
||
BadPostType = GraphQL::ObjectType.define do | ||
name 'Foo' | ||
description 'See also PostType, for a working version of this' | ||
|
||
field :id, !types.String, hash_key: :id | ||
field :user_id, !types.String, hash_key: :user_id | ||
field :title, !types.String # This is the intended broken-ness: missing a hash_key setting | ||
end | ||
|
||
BrokenQueryType = GraphQL::ObjectType.define do | ||
name 'BrokenQuery' | ||
description 'See also QueryType, for a working version of this' | ||
field :posts, !types[!BadPostType] do | ||
argument :user_id, !types.ID | ||
resolve ->(_obj, _args, _ctx) { | ||
[ { id: 'foo1', title: 'titel1', user_id: 'Sven'} ] | ||
} | ||
end | ||
end | ||
|
||
BrokenSchema = GraphQL::Schema.define do | ||
query BrokenQueryType | ||
use ApolloTracing.new | ||
end |