How to use the @graphql-box/helpers.getDirectives function in @graphql-box/helpers

To help you get started, we’ve selected a few @graphql-box/helpers 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 badbatch / graphql-box / packages / request-parser / src / main / index.ts View on Github external
): void {
    const { ancestors, fieldNode, isEntity, isInterface, isUnion, possibleTypes, typeIDKey, typeName } = data;
    const ancestorRequestFieldPath: string[] = [operation];

    ancestors.forEach(ancestor => {
      if (isPlainObject(ancestor) && getKind(ancestor as ASTNode) === FIELD) {
        const ancestorFieldNode = ancestor as FieldNode;
        ancestorRequestFieldPath.push(getAlias(ancestorFieldNode) || (getName(ancestorFieldNode) as string));
      }
    });

    const fieldName = getAlias(fieldNode) || (getName(fieldNode) as string);
    ancestorRequestFieldPath.push(fieldName);
    const requestfieldPath = ancestorRequestFieldPath.join(".");
    const argumentsObjectMap = getArguments(fieldNode);
    const directives = getDirectives(fieldNode);
    let typeIDValue: string | undefined;

    if (argumentsObjectMap) {
      if (argumentsObjectMap[typeIDKey]) {
        typeIDValue = argumentsObjectMap[typeIDKey];
      } else if (variables && variables[typeIDKey]) {
        typeIDValue = variables[typeIDKey];
      }
    }

    fieldTypeMap.set(requestfieldPath, {
      hasArguments: !!argumentsObjectMap,
      hasDirectives: !!directives,
      isEntity,
      isInterface,
      isUnion,
github badbatch / graphql-box / packages / cache-manager / src / main / index.ts View on Github external
private static _getFieldKeysAndPaths(field: FieldNode, options: KeysAndPathsOptions): KeysAndPaths {
    const { index, requestFieldCacheKey = "", requestFieldPath = "", responseDataPath = "" } = options;
    const name = getName(field) as string;

    const updatedRequestFieldCacheKey = CacheManager._buildRequestFieldCacheKey(
      name,
      requestFieldCacheKey,
      getArguments(field),
      getDirectives(field),
      index,
    );

    const fieldAliasOrName = getAlias(field) || name;

    const updatedRequestFieldPath = isNumber(index)
      ? requestFieldPath
      : CacheManager._buildKey(fieldAliasOrName, requestFieldPath);

    const propNameOrIndex = isNumber(index) ? index : fieldAliasOrName;
    const updatedResponseDataPath = CacheManager._buildKey(propNameOrIndex, responseDataPath);

    return {
      hashedRequestFieldCacheKey: hashRequest(updatedRequestFieldCacheKey),
      propNameOrIndex,
      requestFieldCacheKey: updatedRequestFieldCacheKey,