当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript graphql-request.GraphQLClient类代码示例

本文整理汇总了TypeScript中graphql-request.GraphQLClient的典型用法代码示例。如果您正苦于以下问题:TypeScript GraphQLClient类的具体用法?TypeScript GraphQLClient怎么用?TypeScript GraphQLClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GraphQLClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createGraphcoolUser

async function createGraphcoolUser(
  api: GraphQLClient,
  email: string,
  password: string,
): Promise<string> {
  const mutation = `
    mutation createGraphcoolUser($email: String!, $password: String!) {
      createUser(
        email: $email,
        password: $password
      ) {
        id
      }
    }
  `;

  const variables = {
    email,
    password: password,
  };

  return api
    .request<{ createUser: User }>(mutation, variables)
    .then(r => r.createUser.id);
}
开发者ID:davidohayon669,项目名称:este,代码行数:25,代码来源:signup.ts

示例2: getUser

async function getUser(api: GraphQLClient, email: string): Promise<{ User }> {
  const query = `
    query getUser($email: String!) {
      User(email: $email) {
        id
      }
    }
  `;

  const variables = {
    email,
  };

  return api.request<{ User }>(query, variables);
}
开发者ID:davidohayon669,项目名称:este,代码行数:15,代码来源:signup.ts

示例3: getUser

async function getUser(api: GraphQLClient, id: string): Promise<{ User }> {
  const query = `
    query getUser($id: ID!) {
      User(id: $id) {
        id
      }
    }
  `

  const variables = {
    id,
  }

  return api.request<{ User }>(query, variables)
}
开发者ID:davidohayon669,项目名称:este,代码行数:15,代码来源:loggedInUser.ts

示例4: require

import Deploy from './deploy'
import { changedDefaultDefinition } from '../../examples'
import { mockDefinition, Config } from 'prisma-cli-engine'
import default_definition from './nocks/default_definition'
import local_instance from './nocks/local_instance'
import { MockGraphQLClient } from '../../test/mock-client'

jest.mock('graphql-request')
const GraphQLClient = require('graphql-request').GraphQLClient
GraphQLClient.mockImplementation(MockGraphQLClient)

const mockEnv = {
  stages: {
    default: 'dev',
    dev: 'cj8be5ct201is0140cq7qp23b',
  },
}

const localMockEnv = {
  clusters: {
    default: 'local',
    local: {
      token:
        'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1MDcwMjM3NzMsImNsaWVudElkIjoiY2o4YTAxZHN1MDAwMDAxMjM1aWF1aTFoYiJ9.WscmbACu0HqPEDSk_U66TNOskGddmt2plJAew6XCyNw',
      host: 'http://localhost:4466',
    },
  },
}

describe.skip('deploy', () => {
  test('from empty to default definition', async () => {
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:31,代码来源:index.test.ts

示例5: authenticateUser

 async authenticateUser (accessToken: string): Promise<AuthenticatedUser> {
   const mutation = `
     mutation ($accessToken: String!) {
       authenticateUser(
         accessToken: $accessToken
       ) {
         id
         token
         email
       }
     }
   `
   return this.client.request<{ authenticateUser: AuthenticatedUser }>(mutation, { accessToken })
     .then((response) => response.authenticateUser)
 }
开发者ID:timwis,项目名称:textblast,代码行数:15,代码来源:index.ts

示例6: getDatabases

  async getDatabases(): Promise<string[]> {
    const result = await this.client.request<any>(
      `{
      __type(name: "PrismaDatabase") {
        kind
        enumValues {
          name
        }
      }
    }`,
    )

    if (result && result.__type && result.__type.enumValues) {
      return result.__type.enumValues.map(v => v.name)
    }

    return []
  }
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:18,代码来源:prismaDBClient.ts

示例7: getRecipients

 async getRecipients (userId: string): Promise<[Recipient]> {
   const query = `
     query ($userId: ID!) {
       allRecipients(filter: {
         user: {
           id: $userId
         }
       }) {
         id
         tags
         phoneNumber
         name
         createdAt
       }
     }
   `
   return this.client.request<{allRecipients: [Recipient]}>(query, { userId })
     .then((response) => response.allRecipients)
 }
开发者ID:timwis,项目名称:textblast,代码行数:19,代码来源:index.ts

示例8: getDocReviewDate

docNames.subscribe(x => {
  let key = path.basename(x, ".md");

  if (!srcData[key])
    return;

  let vars = {
    "path": "lib/" + srcData[key].path
  };

  client.request(query, vars).then(data => {
      let nodes = data["repository"].ref.target.history.nodes;

      let lastReviewDate = getDocReviewDate(x);//(key + ".md");

      let numUsefulCommits = extractCommitInfo(nodes, lastReviewDate, stoplist);
      let dateString = lastReviewDate.format("YYYY-MM-DD");
      let score = priorityScore(lastReviewDate, numUsefulCommits).toPrecision(3);

      console.log(`'${key}','${dateString}','${numUsefulCommits}','${score}'`);
  });
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:22,代码来源:reviewChecker.ts

示例9: query

  async query(query: string, variables: string[] = []): Promise<any> {
    const finalQuery = this.replace(query, variables)
    const databases = await this.getDatabases()

    if (!databases || !databases[0]) {
      throw new Error(`Prisma Config doesn't have any database connection`)
    }

    return this.client.request(
      `
      mutation executeRaw($query: String! $database: PrismaDatabase) {
        rows: executeRaw(
          database: $database
          query: $query
        )
      }
    `,
      {
        query: finalQuery,
        database: databases[0],
      },
    )
  }
开发者ID:dhruvcodeword,项目名称:prisma,代码行数:23,代码来源:prismaDBClient.ts

示例10: async

const gqlRequest = async (request: string, variables: any) => {
  return await graphQLClient.request(request, variables)
}
开发者ID:adamjq,项目名称:typescript-appsync-graphql,代码行数:3,代码来源:testAppsync.ts


注:本文中的graphql-request.GraphQLClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。