How to use the graphql-anywhere function in graphql-anywhere

To help you get started, we’ve selected a few graphql-anywhere examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github braposo / graphql-css / src / index.js View on Github external
return cxs(el)(props => {
        try {
            const parsedQuery = isGqlQuery(query)
                ? query
                : internalGql(buildQuery(interleave(query, interpolations), props).join(""));

            return smoosh(graphql(resolver, parsedQuery, styles));
        } catch (e) {
            // eslint-disable-next-line no-console
            console.error("Not a valid gql query. Did you forget a prop?");
            return {};
        }
    });
};
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
const context: ReadStoreContext = {
    // Global settings
    store,
    returnPartialData,
    customResolvers: (config && config.customResolvers) || {},
    // Flag set during execution
    hasMissingField: false,
  };

  const rootIdValue = {
    type: 'id',
    id: rootId,
    previousResult,
  };

  const result = graphqlAnywhere(
    readStoreResolver,
    query,
    rootIdValue,
    context,
    variables,
    {
      fragmentMatcher: fragmentMatcherFunction,
      resultMapper,
    },
  );

  return {
    result,
    complete: !context.hasMissingField,
  };
}
github yenbekbay / movie-api / src / kinopoisk / getInfo.js View on Github external
),
    rtCriticsRating: parseInt(ratingData.ratingFilmCritics, 10),
    rtCriticsRatingVoteCount: parseInt(
      (ratingData.ratingFilmCriticsVoteCount || '').replace(' ', ''), 10,
    ),
    stills: (gallery || []).map(
      ({ preview }: KinopoiskApi$GalleryItem) => imageUrlFromPath(
        preview.replace('kadr/sm_', 'kadr/'),
      ),
    ),
    credits,
  };

  if (!query) return finalRes;

  return graphql(R.prop, gql`${query}`, finalRes);
};
github brentvatne / apollo-sqlite-experiment / src / createMemoryNetworkInterface.js View on Github external
async query(request: Request): Promise {
    let result = await graphql(this._resolver, request.query, null, {});

    return {
      data: result,
      errors: [],
    };
  }
github braposo / graphql-css / src / index.js View on Github external
const getStyles = (query, variables) => {
        if (!isGqlQuery(query)) {
            throw new Error("Query must be a valid gql query");
        }

        const generatedStyles = smoosh(graphql(resolver, query, styles, null, variables));

        return generatedStyles;
    };
github olebedev / swarm / packages / db / src / subscription.js View on Github external
buildTree(): {
    tree: Value,
    deps: Dependencies,
    ready: boolean,
  } {
    const ctx = {
      ready: true,
      deps: new Dependencies(),
    };

    const tree = graphql(
      this.resolver.bind(this),
      this.request.query,
      {},
      ctx,
      this.request.variables,
    );

    return {
      tree,
      ready: ctx.ready,
      deps: ctx.deps,
    };
  }
github decidim / decidim / decidim-comments / app / frontend / support / resolve_graphql_query.ts View on Github external
const resolveGraphQLQuery = (document: any, options: any = {}) => {
  const { filterResult, rootValue, context, variables } = options;

  const result = graphql(
    resolver,
    document,
    rootValue,
    context,
    variables
  );

  if (filterResult) {
    return filter(document, result);
  }
  return result;
};
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / readFromStore.js View on Github external
export function diffQueryAgainstStore(_a) {
    var store = _a.store, query = _a.query, variables = _a.variables, previousResult = _a.previousResult, _b = _a.returnPartialData, returnPartialData = _b === void 0 ? true : _b, _c = _a.rootId, rootId = _c === void 0 ? 'ROOT_QUERY' : _c, fragmentMatcherFunction = _a.fragmentMatcherFunction, config = _a.config;
    var queryDefinition = getQueryDefinition(query);
    variables = assign({}, getDefaultValues(queryDefinition), variables);
    var context = {
        store: store,
        returnPartialData: returnPartialData,
        cacheResolvers: (config && config.cacheResolvers) || {},
        hasMissingField: false,
    };
    var rootIdValue = {
        type: 'id',
        id: rootId,
        previousResult: previousResult,
    };
    var result = graphqlAnywhere(readStoreResolver, query, rootIdValue, context, variables, {
        fragmentMatcher: fragmentMatcherFunction,
        resultMapper: resultMapper,
    });
    return {
        result: result,
        complete: !context.hasMissingField,
    };
}
export function assertIdValue(idValue) {
github coralproject / talk / client / coral-framework / hocs / withFragments.js View on Github external
function filter(doc, data) {
  const resolver = (fieldName, root, args, context, info) => {
    return root[info.resultKey];
  };

  return graphql(resolver, doc, data, null, null, { includeAll: true });
}

graphql-anywhere

Run GraphQL queries with no schema and just one resolver

MIT
Latest version published 2 years ago

Package Health Score

80 / 100
Full package analysis