multiQueryUpdater = ({
  typeName,
  fragment,
  fragmentName,
  collection,
  resolverName
}) => (cache, { data }) => {
  const multiResolverName = collection.options.multiResolverName;
  // update multi queries
  const multiQuery = buildMultiQuery({ typeName, fragmentName, fragment });
  const newDoc = data?.[resolverName]?.data;
  // get all the resolvers that match
  const variablesList = getVariablesListFromCache(cache, multiResolverName);
  variablesList.forEach(async variables => {
    try {
      const queryResult = cache.readQuery({ query: multiQuery, variables });
      // get mongo selector and options objects based on current terms
      const terms = variables.input.terms;
      const parameters = terms ? collection.getParameters(terms) : await filterFunction(collection, variables.input, {});
      const { selector, options: paramOptions } = parameters;
      const { sort } = paramOptions;
      // check if the document should be included in this query, given the query filters
      if (matchSelector(newDoc, selector)) {
        // TODO: handle order using the selector
        const newData = addToData({ queryResult, multiResolverName, document: newDoc, sort, selector });
        cache.writeQuery({ query: multiQuery, variables, data: newData });
      }
    } catch (err) {
      // could not find the query
      // TODO: be smarter about the error cases and check only for cache mismatch
      console.log(err);
    }
  });
}
Update cached list of data after a document creation