UNPKG

@apollo/client

Version:

A fully-featured caching GraphQL client.

710 lines (573 loc) 25.2 kB
// This file is used by the error message display website and the // @apollo/client/includeErrors entry point. // This file is not meant to be imported manually. export const errorCodes = { 1: { file: "@apollo/client/utilities/internal/checkDocument.js", condition: "doc && doc.kind === \"Document\"", message: `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \ string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql` }, 2: { file: "@apollo/client/utilities/internal/checkDocument.js", message: `Schema type definitions not allowed in queries. Found: "%s"` }, 3: { file: "@apollo/client/utilities/internal/checkDocument.js", condition: "operations.length <= 1", message: `Ambiguous GraphQL document: contains %s operations` }, 4: { file: "@apollo/client/utilities/internal/checkDocument.js", condition: "operations.length == 1 && operations[0].operation === expectedType", message: `Running a %s requires a graphql ` + `%s, but a %s was used instead.` }, 5: { file: "@apollo/client/utilities/internal/checkDocument.js", message: '`%s` is a forbidden field alias name in the selection set for field `%s` in %s "%s".' }, 6: { file: "@apollo/client/utilities/internal/getFragmentDefinition.js", condition: "doc.kind === \"Document\"", message: `Expecting a parsed GraphQL document. Perhaps you need to wrap the query \ string in a "gql" tag? http://docs.apollostack.com/apollo-client/core.html#gql` }, 7: { file: "@apollo/client/utilities/internal/getFragmentDefinition.js", condition: "doc.definitions.length <= 1", message: "Fragment must have exactly one definition." }, 8: { file: "@apollo/client/utilities/internal/getFragmentDefinition.js", condition: "fragmentDef.kind === \"FragmentDefinition\"", message: "Must be a fragment definition." }, 9: { file: "@apollo/client/utilities/internal/getFragmentFromSelection.js", condition: "fragment", message: `No fragment named %s` }, 10: { file: "@apollo/client/utilities/internal/getFragmentQueryDocument.js", message: `Found a %s operation%s. ` + "No operations are allowed when using a fragment as a query. Only fragments are allowed." }, 11: { file: "@apollo/client/utilities/internal/getFragmentQueryDocument.js", condition: "fragments.length === 1", message: `Found %s fragments. \`fragmentName\` must be provided when there is not exactly 1 fragment.` }, 12: { file: "@apollo/client/utilities/internal/getMainDefinition.js", message: "Expected a parsed GraphQL query with a query, mutation, subscription, or a fragment." }, 13: { file: "@apollo/client/utilities/internal/getQueryDefinition.js", condition: "queryDef && queryDef.operation === \"query\"", message: "Must contain a query definition." }, 15: { file: "@apollo/client/utilities/internal/shouldInclude.js", condition: "evaledValue !== void 0", message: `Invalid variable referenced in @%s directive.` }, 16: { file: "@apollo/client/utilities/internal/shouldInclude.js", condition: "directiveArguments && directiveArguments.length === 1", message: `Incorrect number of arguments for the @%s directive.` }, 17: { file: "@apollo/client/utilities/internal/shouldInclude.js", condition: "ifArgument.name && ifArgument.name.value === \"if\"", message: `Invalid argument for the @%s directive.` }, 18: { file: "@apollo/client/utilities/internal/shouldInclude.js", condition: "ifValue &&\n (ifValue.kind === \"Variable\" || ifValue.kind === \"BooleanValue\")", message: `Argument for the @%s directive must be a variable or a boolean value.` }, 19: { file: "@apollo/client/utilities/internal/valueToObjectRepresentation.js", message: `The inline argument "%s" of kind "%s"` + "is not supported. Use variables instead of inline arguments to " + "overcome this limitation." }, 20: { file: "@apollo/client/utilities/graphql/DocumentTransform.js", condition: "Array.isArray(cacheKeys)", message: "`getCacheKey` must return an array or undefined" }, 21: { file: "@apollo/client/testing/core/mocking/mockLink.js", condition: "max > min", message: "realisticDelay: `min` must be less than `max`" }, 22: { file: "@apollo/client/testing/core/mocking/mockLink.js", condition: "queryWithoutClientOnlyDirectives", message: "query is required" }, 23: { file: "@apollo/client/testing/core/mocking/mockLink.js", condition: "serverQuery", message: "Cannot mock a client-only query. Mocked responses should contain at least one non-client field." }, 24: { file: "@apollo/client/testing/core/mocking/mockLink.js", condition: "(mock.maxUsageCount ?? 1) > 0", message: "Mocked response `maxUsageCount` must be greater than 0. Given %s" }, 25: { file: "@apollo/client/react/ssr/prerenderStatic.js", condition: "renderCount <= maxRerenders", message: `Exceeded maximum rerender count of %d. This either means you have very deep \`useQuery\` waterfalls in your application and need to increase the \`maxRerender\` option to \`prerenderStatic\`, or that you have an infinite render loop in your application.` }, 26: { file: "@apollo/client/react/ssr/prerenderStatic.js", condition: "!signal?.aborted", message: "The operation was aborted before it could be attempted." }, 27: { file: "@apollo/client/react/internal/cache/QueryReference.js", condition: "!queryRef || QUERY_REFERENCE_SYMBOL in queryRef", message: "Expected a QueryRef object, but got something else instead." }, 28: { file: "@apollo/client/react/hooks/useApolloClient.js", condition: "!!client", message: 'Could not find "client" in the context or passed in as an option. ' + "Wrap the root component in an <ApolloProvider>, or pass an ApolloClient " + "instance in via options." }, 29: { file: "@apollo/client/react/hooks/useLazyQuery.js", condition: "resultRef.current", message: "useLazyQuery: '%s' cannot be called before executing the query." }, 30: { file: "@apollo/client/react/hooks/useLazyQuery.js", condition: "!calledDuringRender()", message: "useLazyQuery: 'execute' should not be called during render. To start a query during render, use the 'useQuery' hook." }, 31: { file: "@apollo/client/react/hooks/useLoadableQuery.js", condition: "!calledDuringRender()", message: "useLoadableQuery: 'loadQuery' should not be called during render. To start a query during render, use the 'useBackgroundQuery' hook." }, 32: { file: "@apollo/client/react/hooks/useLoadableQuery.js", condition: "internalQueryRef", message: "The query has not been loaded. Please load the query." }, 33: { file: "@apollo/client/react/hooks/useSubscription.js", condition: "!optionsRef.current.skip", message: "A subscription that is skipped cannot be restarted." }, 35: { file: "@apollo/client/react/hooks/internal/validateSuspenseHookOptions.js", condition: "supportedFetchPolicies.includes(fetchPolicy)", message: `The fetch policy \`%s\` is not supported with suspense.` }, 37: { file: "@apollo/client/react/context/ApolloContext.js", condition: "\"createContext\" in React", message: "Invoking `getApolloContext` in an environment where `React.createContext` is not available.\n" + "The Apollo Client functionality you are trying to use is only available in React Client Components.\n" + 'Please make sure to add "use client" at the top of your file.\n' + // TODO: change to React documentation once React documentation contains information about Client Components "For more information, see https://nextjs.org/docs/getting-started/react-essentials#client-components" }, 38: { file: "@apollo/client/react/context/ApolloProvider.js", condition: "context.client", message: "ApolloProvider was not passed a client instance. Make " + 'sure you pass in your client via the "client" prop.' }, 39: { file: "@apollo/client/masking/maskDefinition.js", condition: "fragment", message: "Could not find fragment with name '%s'." }, 41: { file: "@apollo/client/masking/maskFragment.js", condition: "fragments.length === 1", message: `Found %s fragments. \`fragmentName\` must be provided when there is not exactly 1 fragment.` }, 42: { file: "@apollo/client/masking/maskFragment.js", condition: "!!fragment", message: `Could not find fragment with name "%s".` }, 43: { file: "@apollo/client/masking/maskOperation.js", condition: "definition", message: "Expected a parsed GraphQL document with a query, mutation, or subscription." }, 47: { file: "@apollo/client/local-state/LocalState.js", condition: "hasDirectives([\"client\"], document)", message: "Expected document to contain `@client` fields." }, 48: { file: "@apollo/client/local-state/LocalState.js", condition: "hasDirectives([\"client\"], document)", message: "Expected document to contain `@client` fields." }, 49: { file: "@apollo/client/local-state/LocalState.js", condition: "fragment", message: "No fragment named %s" }, 53: { file: "@apollo/client/local-state/LocalState.js", message: "Could not resolve __typename on object %o returned from resolver '%s'. '__typename' needs to be returned to properly resolve child fields." }, 54: { file: "@apollo/client/local-state/LocalState.js", condition: "fragment", message: `No fragment named %s` }, 55: { file: "@apollo/client/local-state/LocalState.js", condition: "cache.fragmentMatches", message: "The configured cache does not support fragment matching which will lead to incorrect results when executing local resolvers. Please use a cache that implements `fragmetMatches`." }, 57: { file: "@apollo/client/link/persisted-queries/index.js", condition: "options &&\n (typeof options.sha256 === \"function\" ||\n typeof options.generateHash === \"function\")", message: 'Missing/invalid "sha256" or "generateHash" function. Please ' + 'configure one using the "createPersistedQueryLink(options)" options ' + "parameter." }, 58: { file: "@apollo/client/link/persisted-queries/index.js", condition: "forward", message: "PersistedQueryLink cannot be the last link in the chain." }, 59: { file: "@apollo/client/link/http/checkFetcher.js", condition: "fetcher || typeof fetch !== \"undefined\"", message: ` "fetch" has not been found globally and no fetcher has been \ configured. To fix this, install a fetch package (like \ https://www.npmjs.com/package/cross-fetch), instantiate the \ fetcher, and pass it into your HttpLink constructor. For example: import fetch from 'cross-fetch'; import { ApolloClient, HttpLink } from '@apollo/client'; const client = new ApolloClient({ link: new HttpLink({ uri: '/graphql', fetch }) }); ` }, 60: { file: "@apollo/client/link/http/parseAndCheckHttpResponse.js", condition: "response.body && typeof response.body.getReader === \"function\"", message: "Unknown type for `response.body`. Please use a `fetch` implementation that is WhatWG-compliant and that uses WhatWG ReadableStreams for `body`." }, 63: { file: "@apollo/client/link/core/ApolloLink.js", message: "request is not implemented" }, 64: { file: "@apollo/client/incremental/handlers/notImplemented.js", condition: "!hasDirectives([\"defer\"], request.query)", message: "`@defer` is not supported without specifying an incremental handler. Please pass a handler as the `incrementalHandler` option to the `ApolloClient` constructor." }, 65: { file: "@apollo/client/core/ApolloClient.js", condition: "options.cache", message: "To initialize Apollo Client, you must specify a 'cache' property " + "in the options object. \n" + "For more information, please visit: https://go.apollo.dev/c/docs" }, 66: { file: "@apollo/client/core/ApolloClient.js", condition: "options.link", message: "To initialize Apollo Client, you must specify a 'link' property " + "in the options object. \n" + "For more information, please visit: https://go.apollo.dev/c/docs" }, 67: { file: "@apollo/client/core/ApolloClient.js", condition: "options.fetchPolicy !== \"cache-and-network\"", message: "The cache-and-network fetchPolicy does not work with client.query, because " + "client.query can only return a single result. Please use client.watchQuery " + "to receive multiple results from the cache and the network, or consider " + "using a different fetchPolicy, such as cache-first or network-only." }, 68: { file: "@apollo/client/core/ApolloClient.js", condition: "options.fetchPolicy !== \"standby\"", message: "The standby fetchPolicy does not work with client.query, because " + "standby does not fetch. Consider using a different fetchPolicy, such " + "as cache-first or network-only." }, 69: { file: "@apollo/client/core/ApolloClient.js", condition: "options.query", message: "query option is required. You must specify your GraphQL document " + "in the query option." }, 70: { file: "@apollo/client/core/ApolloClient.js", condition: "options.query.kind === \"Document\"", message: 'You must wrap the query string in a "gql" tag.' }, 71: { file: "@apollo/client/core/ApolloClient.js", condition: "!options.returnPartialData", message: "returnPartialData option only supported on watchQuery." }, 72: { file: "@apollo/client/core/ApolloClient.js", condition: "!options.pollInterval", message: "pollInterval option only supported on watchQuery." }, 73: { file: "@apollo/client/core/ApolloClient.js", condition: "!options.notifyOnNetworkStatusChange", message: "notifyOnNetworkStatusChange option only supported on watchQuery." }, 74: { file: "@apollo/client/core/ApolloClient.js", condition: "optionsWithDefaults.mutation", message: "The `mutation` option is required. Please provide a GraphQL document in the `mutation` option." }, 75: { file: "@apollo/client/core/ApolloClient.js", condition: "optionsWithDefaults.fetchPolicy === \"network-only\" ||\n optionsWithDefaults.fetchPolicy === \"no-cache\"", message: "Mutations only support 'network-only' or 'no-cache' fetch policies. The default 'network-only' behavior automatically writes mutation results to the cache. Passing 'no-cache' skips the cache write." }, 77: { file: "@apollo/client/core/ObservableQuery.js", condition: "fetchPolicy === \"standby\"", message: "The `variablesUnknown` option can only be used together with a `standby` fetch policy." }, 79: { file: "@apollo/client/core/ObservableQuery.js", condition: "this.options.fetchPolicy !== \"cache-only\"", message: "Cannot execute `fetchMore` for 'cache-only' query '%s'. Please use a different fetch policy." }, 80: { file: "@apollo/client/core/ObservableQuery.js", condition: "updateQuery", message: "You must provide an `updateQuery` function when using `fetchMore` with a `no-cache` fetch policy." }, 84: { file: "@apollo/client/core/QueryManager.js", message: "QueryManager stopped while query was in flight" }, 85: { file: "@apollo/client/core/QueryManager.js", condition: "this.localState", message: "Mutation '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured." }, 86: { file: "@apollo/client/core/QueryManager.js", message: "Store reset while query was in flight (not completed in link chain)" }, 89: { file: "@apollo/client/core/QueryManager.js", condition: "!this.getDocumentInfo(query).hasClientExports || this.localState", message: "Subscription '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured." }, 90: { file: "@apollo/client/core/QueryManager.js", condition: "this.localState", message: "%s '%s' contains `@client` fields but local state has not been configured." }, 91: { file: "@apollo/client/core/QueryManager.js", condition: "!hasIncrementalDirective", message: "%s '%s' contains `@client` and `@defer` directives. These cannot be used together." }, 92: { file: "@apollo/client/core/QueryManager.js", condition: "this.localState", message: "Query '%s' contains `@client` fields with variables provided by `@export` but local state has not been configured." }, 94: { file: "@apollo/client/core/QueryManager.js", condition: "this.localState", message: "Query '%s' contains `@client` fields but local state has not been configured." }, 95: { file: "@apollo/client/core/QueryManager.js", condition: "didEmitValue", message: "The link chain completed without emitting a value. This is likely unintentional and should be updated to emit a value before completing." }, 96: { file: "@apollo/client/cache/inmemory/entityStore.js", condition: "typeof dataId === \"string\"", message: "store.merge expects a string ID" }, 99: { file: "@apollo/client/cache/inmemory/key-extractor.js", condition: "extracted !== void 0", message: `Missing field '%s' while extracting keyFields from %s` }, 100: { file: "@apollo/client/cache/inmemory/policies.js", condition: "!old || old === which", message: `Cannot change root %s __typename more than once` }, 103: { file: "@apollo/client/cache/inmemory/policies.js", message: "Cannot automatically merge arrays" }, 104: { file: "@apollo/client/cache/inmemory/readFromStore.js", message: `No fragment named %s` }, 105: { file: "@apollo/client/cache/inmemory/readFromStore.js", condition: "!isReference(value)", message: `Missing selection set for object of type %s returned for query field %s` }, 106: { file: "@apollo/client/cache/inmemory/writeToStore.js", message: `Could not identify object %s` }, 108: { file: "@apollo/client/cache/inmemory/writeToStore.js", message: `No fragment named %s` } }; export const devDebug = { 76: { file: "@apollo/client/core/ApolloClient.js", message: `In client.refetchQueries, Promise.all promise rejected with error %o` }, 83: { file: "@apollo/client/core/ObservableQuery.js", message: `Missing cache result fields: %o` } }; export const devLog = {}; export const devWarn = { 36: { file: "@apollo/client/react/hooks/internal/validateSuspenseHookOptions.js", message: "Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy." }, 40: { file: "@apollo/client/masking/maskDefinition.js", message: "Accessing unmasked field on %s at path '%s'. This field will not be available when masking is enabled. Please read the field from the fragment instead." }, 44: { file: "@apollo/client/masking/utils.js", message: "@unmask 'mode' argument does not support variables." }, 45: { file: "@apollo/client/masking/utils.js", message: "@unmask 'mode' argument must be of type string." }, 46: { file: "@apollo/client/masking/utils.js", message: "@unmask 'mode' argument does not recognize value '%s'." }, 50: { file: "@apollo/client/local-state/LocalState.js", message: "The '%s' resolver returned `undefined` instead of a value. This is likely a bug in the resolver. If you didn't mean to return a value, return `null` instead." }, 51: { file: "@apollo/client/local-state/LocalState.js", message: "The '%s' field had no cached value and only forced resolvers were run. The value was set to `null`." }, 52: { file: "@apollo/client/local-state/LocalState.js", message: "The '%s' field on object %o returned `undefined` instead of a value. The parent resolver did not include the property in the returned value and there was no resolver defined for the field." }, 56: { file: "@apollo/client/link/ws/index.js", message: "`WebSocketLink` uses the deprecated and unmaintained `subscriptions-transport-ws` library. This link is no longer maintained and will be removed in a future major version of Apollo Client. We recommend switching to `GraphQLWsLink` which uses the `graphql-ws` library to send GraphQL operations through WebSocket connections (https://the-guild.dev/graphql/ws)." }, 61: { file: "@apollo/client/link/core/ApolloLink.js", message: "[ApolloLink.split]: The test function returned a non-boolean value which could result in subtle bugs (e.g. such as using an `async` function which always returns a truthy value). Got `%o`." }, 62: { file: "@apollo/client/link/core/ApolloLink.js", message: "The terminating link provided to `ApolloLink.execute` called `forward` instead of handling the request. " + "This results in an observable that immediately completes and does not emit a value. " + "Please provide a terminating link that properly handles the request.\n\n" + "If you are using a split link, ensure each branch contains a terminating link that handles the request." }, 78: { file: "@apollo/client/core/ObservableQuery.js", message: `Called refetch(%o) for query %o, which does not declare a $variables variable. Did you mean to call refetch(variables) instead of refetch({ variables })?` }, 82: { file: "@apollo/client/core/ObservableQuery.js", message: "Cannot poll on 'cache-only' query '%s' and as such, polling is disabled. Please use a different fetch policy." }, 87: { file: "@apollo/client/core/QueryManager.js", message: `Unknown query named "%s" requested in refetchQueries options.include array` }, 88: { file: "@apollo/client/core/QueryManager.js", message: `Unknown anonymous query requested in refetchQueries options.include array` }, 93: { file: "@apollo/client/core/QueryManager.js", message: '[%s]: Fragments masked by data masking are inaccessible when using fetch policy "no-cache". Please add `@unmask` to each fragment spread to access the data.' }, 97: { file: "@apollo/client/cache/inmemory/entityStore.js", message: "cache.modify: You are trying to write a Reference that is not part of the store: %o\n" + "Please make sure to set the `mergeIntoStore` parameter to `true` when creating a Reference that is not part of the store yet:\n" + "`toReference(object, true)`" }, 98: { file: "@apollo/client/cache/inmemory/entityStore.js", message: "cache.modify: Writing an array with a mix of both References and Objects will not result in the Objects being normalized correctly.\n" + "Please convert the object instance %o to a Reference before writing it to the cache by calling `toReference(object, true)`." }, 101: { file: "@apollo/client/cache/inmemory/policies.js", message: `Inferring subtype %s of supertype %s` }, 102: { file: "@apollo/client/cache/inmemory/policies.js", message: `Undefined 'from' passed to readField with arguments %s` }, 109: { file: "@apollo/client/cache/inmemory/writeToStore.js", message: `Cache data may be lost when replacing the %s field of a %s object. This could cause additional (usually avoidable) network requests to fetch data that were otherwise cached. To address this problem (which is not a bug in Apollo Client), %sdefine a custom merge function for the %s field, so InMemoryCache can safely merge these objects: existing: %o incoming: %o For more information about these options, please refer to the documentation: * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects ` }, 110: { file: "@apollo/client/cache/core/cache.js", message: "Could not identify object passed to `from` for '%s' fragment, either because the object is non-normalized or the key fields are missing. If you are masking this object, please ensure the key fields are requested by the parent object." } }; export const devError = { 14: { file: "@apollo/client/utilities/internal/removeDirectivesFromDocument.js", message: `Could not find operation or fragment` }, 34: { file: "@apollo/client/react/hooks/useSyncExternalStore.js", message: "The result of getSnapshot should be cached to avoid an infinite loop" }, 81: { file: "@apollo/client/core/ObservableQuery.js", message: "Unhandled GraphQL subscription error" }, 107: { file: "@apollo/client/cache/inmemory/writeToStore.js", message: `Missing field '%s' while writing result %o` } };