diff --git a/client/coral-framework/hocs/withFragments.js b/client/coral-framework/hocs/withFragments.js index f98411de1..98ab76922 100644 --- a/client/coral-framework/hocs/withFragments.js +++ b/client/coral-framework/hocs/withFragments.js @@ -6,27 +6,21 @@ import { getShallowChanges } from 'coral-framework/utils'; import PropTypes from 'prop-types'; import union from 'lodash/union'; -// TODO: Should not depend on `props.data` -// Currently necessary because of this https://github.com/apollographql/graphql-anywhere/issues/38 -function filter(doc, data, variables) { +function filter(doc, data) { const resolver = (fieldName, root, args, context, info) => { return root[info.resultKey]; }; - return graphql(resolver, doc, data, null, variables); + return graphql(resolver, doc, data, null, null, { includeAll: true }); } -// filterProps returns only the property as defined in the fragments. -// TODO: Should not depend on `props.data` function filterProps(props, fragments) { const filtered = {}; Object.keys(fragments).forEach(key => { - if (!(key in props)) { + if (!(key in props) || props[key] === undefined) { return; } - filtered[key] = props.data - ? filter(fragments[key], props[key], props.data.variables) - : props[key]; + filtered[key] = filter(fragments[key], props[key]); }); return filtered; } diff --git a/yarn.lock b/yarn.lock index 251ec050d..13f8f704f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -81,8 +81,8 @@ prettier "^1.10.2" "@coralproject/graphql-anywhere-optimized@^0.1.0": - version "0.1.5" - resolved "https://registry.yarnpkg.com/@coralproject/graphql-anywhere-optimized/-/graphql-anywhere-optimized-0.1.5.tgz#67c862bf908ea717d9521ea76266b5bc9f109c65" + version "0.1.6" + resolved "https://registry.yarnpkg.com/@coralproject/graphql-anywhere-optimized/-/graphql-anywhere-optimized-0.1.6.tgz#073b33764c04788b0290788da9ebf0ed21af6437" dependencies: graphql-ast-tools "^0.2.2"