README.md in rspec-graphql_matchers-1.4.0 vs README.md in rspec-graphql_matchers-2.0.0.pre.rc.0
- old
+ new
@@ -19,15 +19,13 @@
- `expect(a_mutation_type).to have_a_return_field(field_name).returning(valid_type)`
- `expect(a_mutation_type).to have_an_input_field(field_name).of_type(valid_type)`
- `expect(a_field).to be_of_type(valid_type)`
- `expect(an_input).to accept_argument(argument_name).of_type(valid_type)`
-Where a valid type for the expectation is either:
+Where `valid_type` is a your type signature as a String: `"String!"`, `"Int!"`, `"[String]!"` (note the exclamation mark at the end, as required by the [GraphQL specifications](http://graphql.org/).
-- A reference to the actual type you expect;
-- [Recommended] A String representation of a type: `"String!"`, `"Int!"`, `"[String]!"`
- (note the exclamation mark at the end, as required by the [GraphQL specifications](http://graphql.org/).
+Please note that using references to type instances is deprecated and will be removed in a future release.
## Examples
Given a GraphQL object defined as
@@ -42,24 +40,24 @@
field :comments, [String], null: false
field :isPublished, Boolean, null: true
field :published, Boolean, null: false, deprecation_reason: 'Use isPublished instead'
field :subposts, PostType, null: true do
- argument :filter, types.String, required: false
- argument :id, types.ID, required: false
- argument :isPublished, types.Boolean, required: false
+ argument :filter, String, required: false
+ argument :id, ID, required: false
+ argument :isPublished, Boolean, required: false
end
end
```
### 1) Test your type defines the correct fields:
```ruby
describe PostType do
subject { described_class }
- it { is_expected.to have_field(:id).of_type(!types.ID) }
+ it { is_expected.to have_field(:id).of_type("ID!") }
it { is_expected.to have_field(:comments).of_type("[String!]!") }
it { is_expected.to have_field(:isPublished).of_type("Boolean") }
# Check a field is deprecated
it { is_expected.to have_field(:published).with_deprecation_reason }
@@ -121,11 +119,9 @@
it 'implements interface Node' do
expect(subject).to implement('Node')
end
- # Accepts arguments as an array and type objects directly
- it { is_expected.to implement(GraphQL::Types::Relay::Node) }
it { is_expected.not_to implement('OtherInterface') }
end
```
### 5) Using camelize: false on field names