How to use the apollo-utilities.argumentsObjectFromField 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 apollographql / apollo-client / packages / graphql-anywhere / src / async.ts View on Github external
async function executeField(
  field: FieldNode,
  rootValue: any,
  execContext: ExecContext,
): Promise {
  const { variableValues: variables, contextValue, resolver } = execContext;

  const fieldName = field.name.value;
  const args = argumentsObjectFromField(field, variables);

  const info: ExecInfo = {
    isLeaf: !field.selectionSet,
    resultKey: resultKeyNameFromField(field),
    directives: getDirectiveInfoFromField(field, variables),
    field,
  };

  const result = await resolver(fieldName, rootValue, args, contextValue, info);

  // Handle all scalar types here
  if (!field.selectionSet) {
    return result;
  }

  // From here down, the field has a selection set, which means it's trying to
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / executeStoreQuery.ts View on Github external
function executeField(
  field: FieldNode,
  rootValue: any,
  execContext: ExecContext,
): ExecResult {
  const { variableValues: variables, contextValue } = execContext;
  const fieldName = field.name.value;
  const args = argumentsObjectFromField(field, variables);

  const info: ExecInfo = {
    resultKey: resultKeyNameFromField(field),
    directives: getDirectiveInfoFromField(field, variables),
  };

  const readStoreResult = readStoreResolver(
    fieldName,
    rootValue,
    args,
    contextValue,
    info,
  );

  // Handle all scalar types here
  if (!field.selectionSet) {
github Grantimus9 / vuegraphqlphx / assets / node_modules / graphql-anywhere / src / graphql.ts View on Github external
function executeField(
  field: FieldNode,
  rootValue: any,
  execContext: ExecContext,
): any {
  const { variableValues: variables, contextValue, resolver } = execContext;

  const fieldName = field.name.value;
  const args = argumentsObjectFromField(field, variables);

  const info: ExecInfo = {
    isLeaf: !field.selectionSet,
    resultKey: resultKeyNameFromField(field),
    directives: getDirectiveInfoFromField(field, variables),
  };

  const result = resolver(fieldName, rootValue, args, contextValue, info);

  // Handle all scalar types here
  if (!field.selectionSet) {
    return result;
  }

  // From here down, the field has a selection set, which means it's trying to
  // query a GraphQLObjectType
github Lucifier129 / graphql-dynamic / src / graphql-anywhere / index.js View on Github external
async function executeField(field, rootValue, execContext) {
  const { variables, contextValue, resolver } = execContext

  const fieldName = field.name.value
  const args = argumentsObjectFromField(field, variables)

  const info = {
    isLeaf: !field.selectionSet,
    resultKey: resultKeyNameFromField(field),
    directives: getDirectivesFromField(field, variables)
  }

  const result = await resolver(fieldName, rootValue, args, contextValue, info)

  // Handle all scalar types here
  if (!field.selectionSet) {
    return result
  }

  // From here down, the field has a selection set, which means it's trying to
  // query a GraphQLObjectType
github sprusr / ethpollo / src / utils / queries.ts View on Github external
}

      // keep track of info about the original query
      queryInfo[trackerId] = {
        includedFields: [], // TODO: implement - do we need it, or does apollo auto filter?
        name: functionName,
        path: [contractAlias, functionAlias],
        type: QUERY_TYPE,
      };

      // convert contract queries to calls
      return [...queries, createCallQuery({
        abiCoder,
        abiItem,
        address,
        args: argumentsObjectFromField(selection, {}) || {},
        trackerId,
      })];
    }, [] as FieldNode[]);
    return [...acc, ...contractCallQueries];
github apollographql / apollo-client / packages / apollo-client / src / core / LocalState.ts View on Github external
// if we've specifically identified that we only want to run forced
    // resolvers (that is, resolvers for fields marked with
    // `@client(always: true)`), then we'll skip running non-forced resolvers.
    if (
      !execContext.onlyRunForcedResolvers ||
      this.shouldForceResolvers(field)
    ) {
      const resolverType =
        rootValue.__typename || execContext.defaultOperationType;
      const resolverMap = this.resolvers && this.resolvers[resolverType];
      if (resolverMap) {
        const resolve = resolverMap[aliasUsed ? fieldName : aliasedFieldName];
        if (resolve) {
          resultPromise = Promise.resolve(resolve(
            rootValue,
            argumentsObjectFromField(field, variables),
            execContext.context,
            { field, fragmentMap: execContext.fragmentMap },
          ));
        }
      }
    }

    return resultPromise.then((result = defaultResult) => {
      // If an @export directive is associated with the current field, store
      // the `as` export variable name and current result for later use.
      if (field.directives) {
        field.directives.forEach(directive => {
          if (directive.name.value === 'export' && directive.arguments) {
            directive.arguments.forEach(arg => {
              if (arg.name.value === 'as' && arg.value.kind === 'StringValue') {
                execContext.exportedVariables[arg.value.value] = result;
github apollographql / apollo-client / packages / graphql-anywhere / src / graphql.ts View on Github external
function executeField(
  field: FieldNode,
  rootValue: any,
  execContext: ExecContext,
): any {
  const { variableValues: variables, contextValue, resolver } = execContext;

  const fieldName = field.name.value;
  const args = argumentsObjectFromField(field, variables);

  const info: ExecInfo = {
    isLeaf: !field.selectionSet,
    resultKey: resultKeyNameFromField(field),
    directives: getDirectiveInfoFromField(field, variables),
  };

  const result = resolver(fieldName, rootValue, args, contextValue, info);

  // Handle all scalar types here
  if (!field.selectionSet) {
    return result;
  }

  // From here down, the field has a selection set, which means it's trying to
  // query a GraphQLObjectType
github apollographql / apollo-client / packages / apollo-cache-inmemory / src / readFromStore.ts View on Github external
private executeField(
    object: StoreObject,
    typename: string | void,
    field: FieldNode,
    execContext: ExecContext,
  ): ExecResult {
    const { variableValues: variables, contextValue } = execContext;
    const fieldName = field.name.value;
    const args = argumentsObjectFromField(field, variables);

    const info: ExecInfo = {
      resultKey: resultKeyNameFromField(field),
      directives: getDirectiveInfoFromField(field, variables),
    };

    const readStoreResult = readStoreResolver(
      object,
      typename,
      fieldName,
      args,
      contextValue,
      info,
    );

    if (Array.isArray(readStoreResult.result)) {