graphql-fields
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -47,2 +47,6 @@ 'use strict'; | ||
if (options.excludedFields.indexOf(name) !== -1) { | ||
return flattened; | ||
} | ||
if (flattened[name] && flattened[name] !== '__arguments') { | ||
@@ -75,2 +79,3 @@ _extends(flattened[name], flattenAST(a, info, flattened[name])); | ||
options.processArguments = opts.processArguments; | ||
options.excludedFields = opts.excludedFields || []; | ||
return fields.reduce(function (o, ast) { | ||
@@ -77,0 +82,0 @@ return flattenAST(ast, info, o); |
# Changelog | ||
## 1.3.0 (2018-11-15) | ||
### Added | ||
- excludedFields option | ||
## 1.2.1 (2018-10-12) | ||
### Added | ||
- Updated dev dependencies | ||
## 1.2.0 (2018-10-10) | ||
@@ -4,0 +18,0 @@ |
{ | ||
"name": "graphql-fields", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Turns GraphQLResolveInfo into a map of the requested fields", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -120,2 +120,8 @@ # graphql-fields | ||
### Exclude specific fields | ||
Most of the time we don't need `__typename` to be sent to backend/rest api, we can exclude `__typename` using this: | ||
```javascript | ||
const graphqlFields = require('graphql-fields'); | ||
const fieldsWithoutTypeName = graphqlFields(info, {}, { excludedFields: ['__typename'] }); | ||
``` | ||
## Why | ||
@@ -122,0 +128,0 @@ An underlying REST api may only return fields based on query params. |
8327
67
163