How to use the apollo-utilities.getFragmentDefinitions function in apollo-utilities

To help you get started, we’ve selected a few apollo-utilities 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 Grantimus9 / vuegraphqlphx / assets / node_modules / graphql-anywhere / src / graphql.ts View on Github external
export function graphql(
  resolver: Resolver,
  document: DocumentNode,
  rootValue?: any,
  contextValue?: any,
  variableValues?: VariableMap,
  execOptions: ExecOptions = {},
) {
  const mainDefinition = getMainDefinition(document);

  const fragments = getFragmentDefinitions(document);
  const fragmentMap = createFragmentMap(fragments);

  const resultMapper = execOptions.resultMapper;

  // Default matcher always matches all fragments
  const fragmentMatcher = execOptions.fragmentMatcher || (() => true);

  const execContext: ExecContext = {
    fragmentMap,
    contextValue,
    variableValues,
    resultMapper,
    resolver,
    fragmentMatcher,
  };
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / executeStoreQuery.ts View on Github external
export const executeStoreQuery = wrap(function (
  query: DocumentNode,
  rootValue: IdValue,
  contextValue: ReadStoreContext,
  variableValues: VariableMap,
  // Default matcher always matches all fragments
  fragmentMatcher: FragmentMatcher = defaultFragmentMatcher,
): ExecResult {
  const mainDefinition = getMainDefinition(query);
  const fragments = getFragmentDefinitions(query);
  const fragmentMap = createFragmentMap(fragments);
  const execContext: ExecContext = {
    fragmentMap,
    contextValue,
    variableValues,
    fragmentMatcher,
  };

  return executeSelectionSet(
    mainDefinition.selectionSet,
    rootValue,
    execContext,
  );
}, {
  makeCacheKey(
github Lucifier129 / graphql-dynamic / src / graphql-anywhere / index.js View on Github external
function graphql(
  resolver,
  document,
  rootValue,
  contextValue,
  variables,
  execOptions = {}
) {
  const mainDefinition = getMainDefinition(document)

  const fragments = getFragmentDefinitions(document)
  const fragmentMap = createFragmentMap(fragments)

  const resultMapper = execOptions.resultMapper

  // Default matcher always matches all fragments
  const fragmentMatcher = execOptions.fragmentMatcher || (() => true)

  const execContext = {
    fragmentMap,
    contextValue,
    variables,
    resultMapper,
    resolver,
    fragmentMatcher
  }
github apollographql / apollo-client / packages / graphql-anywhere / src / graphql.ts View on Github external
export function graphql(
  resolver: Resolver,
  document: DocumentNode,
  rootValue?: any,
  contextValue?: any,
  variableValues?: VariableMap,
  execOptions: ExecOptions = {},
) {
  const mainDefinition = getMainDefinition(document);

  const fragments = getFragmentDefinitions(document);
  const fragmentMap = createFragmentMap(fragments);

  const resultMapper = execOptions.resultMapper;

  // Default matcher always matches all fragments
  const fragmentMatcher = execOptions.fragmentMatcher || (() => true);

  const execContext: ExecContext = {
    fragmentMap,
    contextValue,
    variableValues,
    resultMapper,
    resolver,
    fragmentMatcher,
  };
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / writeToStore.ts View on Github external
try {
      return this.writeSelectionSetToStore({
        result,
        dataId,
        selectionSet: operationDefinition.selectionSet,
        context: {
          store,
          processedData: {},
          variables: assign(
            {},
            getDefaultValues(operationDefinition),
            variables,
          ),
          dataIdFromObject,
          fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
          fragmentMatcherFunction,
        },
      });
    } catch (e) {
      throw enhanceErrorWithDocument(e, document);
    }
  }
github apollographql / apollo-client / packages / apollo-client / src / core / LocalState.ts View on Github external
private async resolveDocument(
    document: DocumentNode,
    rootValue: TData,
    context: any = {},
    variables: VariableMap = {},
    fragmentMatcher: FragmentMatcher = () => true,
    onlyRunForcedResolvers: boolean = false,
  ) {
    const mainDefinition = getMainDefinition(document);
    const fragments = getFragmentDefinitions(document);
    const fragmentMap = createFragmentMap(fragments);

    const definitionOperation = (mainDefinition as OperationDefinitionNode)
      .operation;

    const defaultOperationType = definitionOperation
      ? capitalizeFirstLetter(definitionOperation)
      : 'Query';

    const { cache, client } = this;
    const execContext: ExecContext = {
      fragmentMap,
      context: {
        ...context,
        cache,
        client,
github Grantimus9 / vuegraphqlphx / assets / node_modules / apollo-cache-inmemory / lib / writeToStore.js View on Github external
export function writeResultToStore(_a) {
    var dataId = _a.dataId, result = _a.result, document = _a.document, _b = _a.storeFactory, storeFactory = _b === void 0 ? defaultNormalizedCacheFactory : _b, _c = _a.store, store = _c === void 0 ? storeFactory() : _c, variables = _a.variables, dataIdFromObject = _a.dataIdFromObject, fragmentMatcherFunction = _a.fragmentMatcherFunction;
    var operationDefinition = getOperationDefinition(document);
    var selectionSet = operationDefinition.selectionSet;
    var fragmentMap = createFragmentMap(getFragmentDefinitions(document));
    variables = assign({}, getDefaultValues(operationDefinition), variables);
    try {
        return writeSelectionSetToStore({
            result: result,
            dataId: dataId,
            selectionSet: selectionSet,
            context: {
                store: store,
                storeFactory: storeFactory,
                processedData: {},
                variables: variables,
                dataIdFromObject: dataIdFromObject,
                fragmentMap: fragmentMap,
                fragmentMatcherFunction: fragmentMatcherFunction,
            },
        });