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


TypeScript graphql.getOperationAST函數代碼示例

本文整理匯總了TypeScript中graphql.getOperationAST函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getOperationAST函數的具體用法?TypeScript getOperationAST怎麽用?TypeScript getOperationAST使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: getOperationAST

export const isASubscriptionOperation = (document: DocumentNode, operationName: string): boolean => {
  const operationAST = getOperationAST(document, operationName);

  return !!operationAST && operationAST.operation === 'subscription';
};
開發者ID:apollostack,項目名稱:test-websocket-server,代碼行數:5,代碼來源:is-subscriptions.ts

示例2: getOperationAST

 rootValue: (documentNode: DocumentNode) => {
   const op = getOperationAST(documentNode, undefined);
   return op.operation === 'query'
     ? expectedQuery
     : expectedMutation;
 },
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:6,代碼來源:index.ts

示例3: isQueryOperation

function isQueryOperation(query: DocumentNode, operationName: string) {
  const operationAST = getOperationAST(query, operationName);
  return operationAST.operation === 'query';
}
開發者ID:convoyinc,項目名稱:apollo-server,代碼行數:4,代碼來源:runHttpQuery.ts

示例4: getOperationAST

 operation => {
     const operationAST = getOperationAST(operation.query, operation.operationName);
     return !!operationAST && operationAST.operation === 'subscription';
 },
開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:4,代碼來源:apollo-client.ts

示例5: initializeExtensionStack


//.........這裏部分代碼省略.........

      if (validationErrors.length === 0) {
        validationDidEnd();
      } else {
        validationDidEnd(validationErrors);
        return sendErrorResponse(validationErrors, ValidationError);
      }

      if (config.documentStore) {
        // The underlying cache store behind the `documentStore` returns a
        // `Promise` which is resolved (or rejected), eventually, based on the
        // success or failure (respectively) of the cache save attempt.  While
        // it's certainly possible to `await` this `Promise`, we don't care about
        // whether or not it's successful at this point.  We'll instead proceed
        // to serve the rest of the request and just hope that this works out.
        // If it doesn't work, the next request will have another opportunity to
        // try again.  Errors will surface as warnings, as appropriate.
        //
        // While it shouldn't normally be necessary to wrap this `Promise` in a
        // `Promise.resolve` invocation, it seems that the underlying cache store
        // is returning a non-native `Promise` (e.g. Bluebird, etc.).
        Promise.resolve(
          config.documentStore.set(queryHash, requestContext.document),
        ).catch(err =>
          console.warn('Could not store validated document.', err),
        );
      }
    }

    // FIXME: If we want to guarantee an operation has been set when invoking
    // `willExecuteOperation` and executionDidStart`, we need to throw an
    // error here and not leave this to `buildExecutionContext` in
    // `graphql-js`.
    const operation = getOperationAST(
      requestContext.document,
      request.operationName,
    );

    requestContext.operation = operation || undefined;
    // We'll set `operationName` to `null` for anonymous operations.
    requestContext.operationName =
      (operation && operation.name && operation.name.value) || null;

    await dispatcher.invokeHookAsync(
      'didResolveOperation',
      requestContext as WithRequired<
        typeof requestContext,
        'document' | 'operation' | 'operationName'
      >,
    );

    // Now that we've gone through the pre-execution phases of the request
    // pipeline, and given plugins appropriate ability to object (by throwing
    // an error) and not actually write, we'll write to the cache if it was
    // determined earlier in the request pipeline that we should do so.
    if (persistedQueryRegister && persistedQueryCache) {
      Promise.resolve(persistedQueryCache.set(queryHash, query)).catch(
        console.warn,
      );
    }

    const executionDidEnd = await dispatcher.invokeDidStartHook(
      'executionDidStart',
      requestContext as WithRequired<
        typeof requestContext,
        'document' | 'operation' | 'operationName'
開發者ID:apollostack,項目名稱:apollo-server,代碼行數:67,代碼來源:requestPipeline.ts


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