当前位置: 首页>>代码示例>>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;未经允许,请勿转载。