README.md in rspec-graphql_matchers-1.2.1 vs README.md in rspec-graphql_matchers-1.3.0
- old
+ new
@@ -44,14 +44,16 @@
implements GraphQL::Relay::Node.interface
field :id, ID, null: false
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
end
end
```
### 1) Test your type defines the correct fields:
@@ -62,10 +64,16 @@
it { is_expected.to have_field(:id).of_type(!types.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 }
+ it { is_expected.to have_field(:published).with_deprecation_reason('Use isPublished instead') }
+ it { is_expected.not_to have_field(:published).with_deprecation_reason('Wrong reason') }
+ it { is_expected.not_to have_field(:isPublished).with_deprecation_reason }
+
# The gem automatically converts field names to CamelCase, so this will
# pass even though the field was defined as field :isPublished
it { is_expected.to have_field(:is_published).of_type("Boolean") }
end
```
@@ -120,9 +128,13 @@
expect(subject).to accept_argument(:filter).of_type('String')
expect(subject).to accept_argument(:id).of_type('ID')
end
it { is_expected.not_to accept_argument(:weirdo) }
+
+ # The gem automatically converts argument names to CamelCase, so this will
+ # pass even though the argument was defined as :isPublished
+ it { is_expected.to accept_argument(:is_published).of_type("Boolean") }
end
end
```
### 5) Test an object's interface implementations: