apollo-utilities

  • Version 1.3.4
  • Published
  • 567 kB
  • 4 dependencies
  • MIT license

Install

npm i apollo-utilities
yarn add apollo-utilities
pnpm add apollo-utilities

Overview

Utilities for working with GraphQL ASTs

Index

Variables

Functions

Interfaces

Type Aliases

Namespaces

Variables

variable canUseWeakMap

const canUseWeakMap: boolean;

    Functions

    function addTypenameToDocument

    addTypenameToDocument: (doc: any) => any;

      function argumentsObjectFromField

      argumentsObjectFromField: (
      field: FieldNode | DirectiveNode,
      variables: Object
      ) => Object;

        function assign

        assign: {
        <A, B>(a: A, b: B): A & B;
        <A, B, C>(a: A, b: B, c: C): A & B & C;
        <A, B, C, D>(a: A, b: B, c: C, d: D): A & B & C & D;
        <A, B, C, D, E>(a: A, b: B, c: C, d: D, e: E): A & B & C & D & E;
        (target: any, ...sources: any[]): any;
        };

          function buildQueryFromSelectionSet

          buildQueryFromSelectionSet: (document: any) => any;

            function checkDocument

            checkDocument: (doc: any) => any;

              function cloneDeep

              cloneDeep: <T>(value: T) => T;

                function createFragmentMap

                createFragmentMap: (fragments?: FragmentDefinitionNode[]) => FragmentMap;

                  function getDefaultValues

                  getDefaultValues: (
                  definition: OperationDefinitionNode | undefined
                  ) => { [key: string]: JsonValue };

                    function getDirectiveInfoFromField

                    getDirectiveInfoFromField: (field: any, variables: Object) => DirectiveInfo;

                      function getDirectiveNames

                      getDirectiveNames: (doc: any) => string[];

                        function getDirectivesFromDocument

                        getDirectivesFromDocument: (directives: GetDirectiveConfig[], doc: any) => any;

                          function getEnv

                          getEnv: () => string | undefined;

                            function getFragmentDefinition

                            getFragmentDefinition: (doc: any) => any;

                              function getFragmentDefinitions

                              getFragmentDefinitions: (doc: any) => FragmentDefinitionNode[];

                                function getFragmentQueryDocument

                                getFragmentQueryDocument: (document: any, fragmentName?: string) => any;

                                  function getInclusionDirectives

                                  getInclusionDirectives: (
                                  directives: ReadonlyArray<DirectiveNode>
                                  ) => InclusionDirectives;

                                    function getMainDefinition

                                    getMainDefinition: (
                                    queryDoc: any
                                    ) => OperationDefinitionNode | FragmentDefinitionNode;

                                      function getMutationDefinition

                                      getMutationDefinition: (doc: any) => any;

                                        function getOperationDefinition

                                        getOperationDefinition: (doc: any) => OperationDefinitionNode | undefined;

                                          function getOperationDefinitionOrDie

                                          getOperationDefinitionOrDie: (document: any) => any;

                                            function getOperationName

                                            getOperationName: (doc: any) => string | null;

                                              function getQueryDefinition

                                              getQueryDefinition: (doc: any) => any;

                                                function getStoreKeyName

                                                getStoreKeyName: (
                                                fieldName: string,
                                                args?: Object,
                                                directives?: Directives
                                                ) => string;

                                                  function graphQLResultHasError

                                                  graphQLResultHasError: (result: any) => number;

                                                    function hasClientExports

                                                    hasClientExports: (document: any) => boolean;

                                                      function hasDirectives

                                                      hasDirectives: (names: string[], doc: any) => boolean;

                                                        function isDevelopment

                                                        isDevelopment: () => boolean;

                                                          function isEnv

                                                          isEnv: (env: string) => boolean;

                                                            function isField

                                                            isField: (selection: any) => selection is any;

                                                              function isIdValue

                                                              isIdValue: (idObject: StoreValue) => idObject is IdValue;

                                                                function isInlineFragment

                                                                isInlineFragment: (selection: any) => selection is any;

                                                                  function isJsonValue

                                                                  isJsonValue: (jsonObject: StoreValue) => jsonObject is JsonValue;

                                                                    function isNumberValue

                                                                    isNumberValue: (value: any) => value is any;

                                                                      function isProduction

                                                                      isProduction: () => boolean;

                                                                        function isScalarValue

                                                                        isScalarValue: (value: any) => value is any;

                                                                          function isTest

                                                                          isTest: () => boolean;

                                                                            function maybeDeepFreeze

                                                                            maybeDeepFreeze: (obj: any) => any;

                                                                              function mergeDeep

                                                                              mergeDeep: <T extends any[]>(...sources: T) => TupleToIntersection<T>;

                                                                                function mergeDeepArray

                                                                                mergeDeepArray: <T>(sources: T[]) => T;

                                                                                  function removeArgumentsFromDocument

                                                                                  removeArgumentsFromDocument: (config: RemoveArgumentsConfig[], doc: any) => any;

                                                                                    function removeClientSetsFromDocument

                                                                                    removeClientSetsFromDocument: (document: any) => DocumentNode | null;

                                                                                      function removeConnectionDirectiveFromDocument

                                                                                      removeConnectionDirectiveFromDocument: (doc: any) => any;

                                                                                        function removeDirectivesFromDocument

                                                                                        removeDirectivesFromDocument: (
                                                                                        directives: RemoveDirectiveConfig[],
                                                                                        doc: any
                                                                                        ) => DocumentNode | null;

                                                                                          function removeFragmentSpreadFromDocument

                                                                                          removeFragmentSpreadFromDocument: (
                                                                                          config: RemoveFragmentSpreadConfig[],
                                                                                          doc: any
                                                                                          ) => any;

                                                                                            function resultKeyNameFromField

                                                                                            resultKeyNameFromField: (field: any) => string;

                                                                                              function shouldInclude

                                                                                              shouldInclude: (selection: any, variables?: { [name: string]: any }) => boolean;

                                                                                                function storeKeyNameFromField

                                                                                                storeKeyNameFromField: (field: any, variables?: Object) => string;

                                                                                                  function stripSymbols

                                                                                                  stripSymbols: <T>(data: T) => T;

                                                                                                    function toIdValue

                                                                                                    toIdValue: (idConfig: string | IdConfig, generated?: boolean) => IdValue;

                                                                                                      function tryFunctionOrLogError

                                                                                                      tryFunctionOrLogError: (f: Function) => any;

                                                                                                        function valueFromNode

                                                                                                        valueFromNode: (node: any, onVariable?: VariableValue) => any;

                                                                                                          function valueToObjectRepresentation

                                                                                                          valueToObjectRepresentation: (
                                                                                                          argObj: any,
                                                                                                          name: any,
                                                                                                          value: any,
                                                                                                          variables?: Object
                                                                                                          ) => void;

                                                                                                            function variablesInOperation

                                                                                                            variablesInOperation: (operation: any) => Set<string>;

                                                                                                              function warnOnceInDevelopment

                                                                                                              warnOnceInDevelopment: (msg: string, type?: string) => void;

                                                                                                                Interfaces

                                                                                                                interface FragmentMap

                                                                                                                interface FragmentMap {}

                                                                                                                  index signature

                                                                                                                  [fragmentName: string]: FragmentDefinitionNode;

                                                                                                                    interface IdValue

                                                                                                                    interface IdValue {}

                                                                                                                      property generated

                                                                                                                      generated: boolean;

                                                                                                                        property id

                                                                                                                        id: string;

                                                                                                                          property type

                                                                                                                          type: 'id';

                                                                                                                            property typename

                                                                                                                            typename: string | undefined;

                                                                                                                              interface JsonValue

                                                                                                                              interface JsonValue {}

                                                                                                                                property json

                                                                                                                                json: any;

                                                                                                                                  property type

                                                                                                                                  type: 'json';

                                                                                                                                    Type Aliases

                                                                                                                                    type DirectiveInfo

                                                                                                                                    type DirectiveInfo = {
                                                                                                                                    [fieldName: string]: {
                                                                                                                                    [argName: string]: any;
                                                                                                                                    };
                                                                                                                                    };

                                                                                                                                      type Directives

                                                                                                                                      type Directives = {
                                                                                                                                      [directiveName: string]: {
                                                                                                                                      [argName: string]: any;
                                                                                                                                      };
                                                                                                                                      };

                                                                                                                                        type GetDirectiveConfig

                                                                                                                                        type GetDirectiveConfig = GetNodeConfig<DirectiveNode>;

                                                                                                                                          type GetFragmentSpreadConfig

                                                                                                                                          type GetFragmentSpreadConfig = GetNodeConfig<FragmentSpreadNode>;

                                                                                                                                            type GetNodeConfig

                                                                                                                                            type GetNodeConfig<N> = {
                                                                                                                                            name?: string;
                                                                                                                                            test?: (node: N) => boolean;
                                                                                                                                            };

                                                                                                                                              type IdConfig

                                                                                                                                              type IdConfig = {
                                                                                                                                              id: string;
                                                                                                                                              typename: string | undefined;
                                                                                                                                              };

                                                                                                                                                type InclusionDirectives

                                                                                                                                                type InclusionDirectives = Array<{
                                                                                                                                                directive: DirectiveNode;
                                                                                                                                                ifArgument: ArgumentNode;
                                                                                                                                                }>;

                                                                                                                                                  type ListValue

                                                                                                                                                  type ListValue = Array<null | IdValue>;

                                                                                                                                                    type NumberValue

                                                                                                                                                    type NumberValue = IntValueNode | FloatValueNode;

                                                                                                                                                      type RemoveArgumentsConfig

                                                                                                                                                      type RemoveArgumentsConfig = RemoveNodeConfig<ArgumentNode>;

                                                                                                                                                        type RemoveDirectiveConfig

                                                                                                                                                        type RemoveDirectiveConfig = RemoveNodeConfig<DirectiveNode>;

                                                                                                                                                          type RemoveFragmentDefinitionConfig

                                                                                                                                                          type RemoveFragmentDefinitionConfig = RemoveNodeConfig<FragmentDefinitionNode>;

                                                                                                                                                            type RemoveFragmentSpreadConfig

                                                                                                                                                            type RemoveFragmentSpreadConfig = RemoveNodeConfig<FragmentSpreadNode>;

                                                                                                                                                              type RemoveNodeConfig

                                                                                                                                                              type RemoveNodeConfig<N> = {
                                                                                                                                                              name?: string;
                                                                                                                                                              test?: (node: N) => boolean;
                                                                                                                                                              remove?: boolean;
                                                                                                                                                              };

                                                                                                                                                                type RemoveVariableDefinitionConfig

                                                                                                                                                                type RemoveVariableDefinitionConfig = RemoveNodeConfig<VariableDefinitionNode>;

                                                                                                                                                                  type ScalarValue

                                                                                                                                                                  type ScalarValue = StringValueNode | BooleanValueNode | EnumValueNode;

                                                                                                                                                                    type StoreValue

                                                                                                                                                                    type StoreValue =
                                                                                                                                                                    | number
                                                                                                                                                                    | string
                                                                                                                                                                    | string[]
                                                                                                                                                                    | IdValue
                                                                                                                                                                    | ListValue
                                                                                                                                                                    | JsonValue
                                                                                                                                                                    | null
                                                                                                                                                                    | undefined
                                                                                                                                                                    | void
                                                                                                                                                                    | Object;

                                                                                                                                                                      type TupleToIntersection

                                                                                                                                                                      type TupleToIntersection<T extends any[]> = T extends [infer A]
                                                                                                                                                                      ? A
                                                                                                                                                                      : T extends [infer A, infer B]
                                                                                                                                                                      ? A & B
                                                                                                                                                                      : T extends [infer A, infer B, infer C]
                                                                                                                                                                      ? A & B & C
                                                                                                                                                                      : T extends [infer A, infer B, infer C, infer D]
                                                                                                                                                                      ? A & B & C & D
                                                                                                                                                                      : T extends [infer A, infer B, infer C, infer D, infer E]
                                                                                                                                                                      ? A & B & C & D & E
                                                                                                                                                                      : T extends (infer U)[]
                                                                                                                                                                      ? U
                                                                                                                                                                      : any;

                                                                                                                                                                        type VariableValue

                                                                                                                                                                        type VariableValue = (node: VariableNode) => any;

                                                                                                                                                                          Namespaces

                                                                                                                                                                          namespace fast-json-stable-stringify

                                                                                                                                                                          module 'fast-json-stable-stringify' {}

                                                                                                                                                                            Package Files (16)

                                                                                                                                                                            Dependencies (4)

                                                                                                                                                                            Dev Dependencies (0)

                                                                                                                                                                            No dev dependencies.

                                                                                                                                                                            Peer Dependencies (1)

                                                                                                                                                                            Badge

                                                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/apollo-utilities.

                                                                                                                                                                            • Markdown
                                                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/apollo-utilities)
                                                                                                                                                                            • HTML
                                                                                                                                                                              <a href="https://www.jsdocs.io/package/apollo-utilities"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>