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


TypeScript graphql.print函數代碼示例

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


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

示例1: it

 it('should be able to alias a document containing a query and a named fragment', () => {
   const doc = gql`
     query authorStuff {
       author {
          ...authorDetails
       }
     }
     fragment authorDetails on Author {
       firstName
       lastName
     }`;
   const exp = gql`
     query authorStuff {
       ___authorStuff___requestIndex_2___fieldIndex_0: author {
         ...___authorStuff___requestIndex_2___authorDetails
       }
     }
     fragment ___authorStuff___requestIndex_2___authorDetails on Author {
       ___authorStuff___requestIndex_2___fieldIndex_1: firstName
       ___authorStuff___requestIndex_2___fieldIndex_2: lastName
     }
     `;
   const aliasName = getOperationDefinitionName(getQueryDefinition(doc), 2);
   const aliasedDoc = applyAliasNameToDocument(doc, aliasName);
   assert.equal(print(aliasedDoc), print(exp));
 });
開發者ID:Vanuan,項目名稱:apollo-client,代碼行數:26,代碼來源:queryMerging.ts

示例2: it

    it('should also remove variables when removing empty selection sets', async () => {
      const query = parse(`
      query customerQuery($id: ID!, $limit: Int) {
        customerById(id: $id) {
          id
          name
          bookings(limit: $limit) {
            paid
          }
        }
      }
      `);
      const filteredQuery = filter.transformRequest({
        document: query,
        variables: {
          id: 'c1',
          limit: 10
        }
      });

      const expected = parse(`
      query customerQuery($id: ID!) {
        customerById(id: $id) {
          id
          name
        }
      }
      `);
      expect(print(filteredQuery.document)).to.equal(print(expected));
    });
開發者ID:apollostack,項目名稱:graphql-tools,代碼行數:30,代碼來源:testTransforms.ts

示例3: test

 test("simple case", () => {
     const operation = createOperation({}, {
         query: gql`
             subscription Foo {
                 commentAdded {
                     id
                     text
                 }
             }
         `,
     });
     operation.operationName = "Foo";
     const result = subscriptionToQuery(introspectionResult, operation);
     expect(result).toBeDefined();
     const query = result!["commentAdded"];
     expect(query).toBeDefined();
     const expected = gql`
         query Resolve_Foo_commentAdded ($id: ID!) {
             commentAdded: node(id: $id) {
                 ... on Comment {
                     id
                     text
                 }
             }
         }
     `;
     delete (query as any).loc;
     delete expected.loc;
     expect(print(query)).toEqual(print(expected));
     expect(query).toEqual(expected);
 });
開發者ID:vvakame,項目名稱:til,代碼行數:31,代碼來源:documentModifier.test.ts


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