Skip to content

Commit

Permalink
update changelog and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoldfinger committed May 1, 2017
1 parent 762f745 commit 559f6e1
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### vNEXT

- Updated `graphql` dependency to resolve test failures ([wording change](https://github.com/graphql/graphql-js/commit/ba401e154461bca5323ca9121c6dacaee10ebe88), no API change) [jnwng](https://github.com/jnwng)
- Add lint rule to enforce that required fields are specified. [rgoldfinger](https://github.com/rgoldfinger) in [#47](https://github.com/apollographql/eslint-plugin-graphql/pull/50)

### v0.7.0
- Add lint rule to enforce that operations have names [gauravmk](https://github.com/gauravmk) in [#47](https://github.com/apollographql/eslint-plugin-graphql/pull/47)
Expand Down
85 changes: 84 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ query {
}
```

The rule is defined as `graphql/named-operations` and requires a `schema` and optional `tagName`
The rule is defined as `graphql/named-operations` and requires a `schema` and optional `tagName`.

```js
// In a file called .eslintrc.js
Expand All @@ -283,3 +283,86 @@ module.exports = {
]
}
```
### Required Fields Validation Rule

The Required Fields rule validates that any specified required field is part of the query, but only if that field is available in schema. This is useful to ensure that query results are cached properly in the client.

**Pass**
```
// 'uuid' required
schema {
query {
viewer {
uuid
name
}
}
}
query ViewerName {
viewer {
name
uuid
}
}
```

**Pass**
```
// 'uuid' required
schema {
query {
viewer {
name
}
}
}
query ViewerName {
viewer {
name
}
}
```

**Fail**
```
// 'uuid' required
schema {
query {
viewer {
uuid
name
}
}
}
query ViewerName {
viewer {
name
}
}
```

The rule is defined as `graphql/required-fields` and requires a `schema` and `requiredFields`, with an optional `tagName`.

```js
// In a file called .eslintrc.js
module.exports = {
rules: {
'graphql/required-fields': [
'error',
{
schemaJsonFilepath: require('./schema.json'),
requiredFields: ['uuid'],
},
],
},
plugins: [
'graphql'
]
}
```

0 comments on commit 559f6e1

Please sign in to comment.