當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Operation.getContext方法代碼示例

本文整理匯總了TypeScript中apollo-link.Operation.getContext方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Operation.getContext方法的具體用法?TypeScript Operation.getContext怎麽用?TypeScript Operation.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apollo-link.Operation的用法示例。


在下文中一共展示了Operation.getContext方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: terminatingCheck

 terminatingCheck(done, () => {
   // The batch should've been fired by now.
   expect(operation.getContext()).toEqual({ response: { data } });
   expect(operation2.getContext()).toEqual({ response: { data: data2 } });
   expect(operation3.getContext()).toEqual({ response: { data } });
   expect(batcher.queuedRequests.get('')).toBeUndefined();
 }),
開發者ID:SET001,項目名稱:apollo-link,代碼行數:7,代碼來源:batchLink.ts

示例2: Error

            entityObserver.subscribe(entity => {
                const query = queries[entity.fieldName];
                if (!query) {
                    throw new Error(`unknown fieldName: ${entity.fieldName}`);
                }

                let executeQuery = this._executeQuery;
                if (!executeQuery) {
                    const client: ApolloClient<never> = operation.getContext().client;
                    if (client instanceof ApolloClient === false) {
                        console.error(`client can't fine`, operation.getContext());
                        throw new Error(`client can't find`);
                    }

                    executeQuery = ({ query, variables }) => {
                        return client.query({
                            query,
                            variables,
                        });
                    };
                }

                executeQuery({
                    query,
                    variables: { id: entity.id },
                })
                    .then(result => {
                        observer.next(result);
                    })
                    .catch(e => {
                        observer.error(e);
                    });
            });
開發者ID:vvakame,項目名稱:til,代碼行數:33,代碼來源:subscriptionLinkConvert.ts

示例3: selectURI

      ((operation: Operation) => {
        const context = operation.getContext();

        const contextConfig = {
          http: context.http,
          options: context.fetchOptions,
          credentials: context.credentials,
          headers: context.headers,
        };

        //may throw error if config not serializable
        return selectURI(operation, uri) + JSON.stringify(contextConfig);
      });
開發者ID:SET001,項目名稱:apollo-link,代碼行數:13,代碼來源:batchHttpLink.ts

示例4: graphql

          next: ({ data, errors }) => {
            const observerErrorHandler = observer.error.bind(observer);
            const context = operation.getContext();

            handlingNext = true;
            //data is from the server and provides the root value to this GraphQL resolution
            //when there is no resolver, the data is taken from the context
            graphql(resolver, query, data, context, operation.variables, {
              fragmentMatcher,
            })
              .then(nextData => {
                observer.next({
                  data: nextData,
                  errors,
                });
                if (complete) {
                  observer.complete();
                }
                handlingNext = false;
              })
              .catch(observerErrorHandler);
          },
開發者ID:petermichuncc,項目名稱:scanner,代碼行數:22,代碼來源:index.ts

示例5: setter

 .then(req => setter(req, operation.getContext()))
開發者ID:SET001,項目名稱:apollo-link,代碼行數:1,代碼來源:index.ts


注:本文中的apollo-link.Operation.getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。