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


TypeScript GraphQLClient.request方法代码示例

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


在下文中一共展示了GraphQLClient.request方法的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: async

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

示例10: callbackRuntime

export default callbackRuntime(async (event: APIGatewayEvent) => {
  // NOTE currently needed for backward compatibility
  if (event.path.split('/')[1] !== 'v1') {
    try {
      // log projectId of projects using the old API version
      const client = new GraphQLClient(process.env['GRAPHCOOL_ENDPOINT']!, {
        headers: {
          Authorization: `Bearer ${process.env['GRAPHCOOL_PAT']}`,
        },
      })

      await client.request(`mutation {
        createApiUser(projectId: "${event.path.split('/')[1]}") { id }
      }`)
    } catch (e) {
      if (e.response.errors[0].code !== 3010) {
        throw e
      }
    }

    return {
      statusCode: 301,
      body: '',
      headers: {
        Location: `https://images.graph.cool/v1${event.path}`,
      },
    }
  }

  const [paramsErr, params] = parseParams(event.path)

  if (paramsErr) {
    return {
      statusCode: 400,
      body: paramsErr.toString(),
    }
  }

  const { projectId, fileSecret, crop, resize } = params!

  const options = {
    Bucket: process.env['BUCKET_NAME']!,
    Key: `${projectId}/${fileSecret}`,
  }

  const {
    ContentLength,
    ContentType,
    ContentDisposition,
  } = await s3.headObject(options).promise()

  if (ContentLength! > 25 * 1024 * 1024) {
    return {
      statusCode: 400,
      body: 'File too big',
    }
  }

  if (!ContentType!.includes('image')) {
    return {
      statusCode: 400,
      body: 'File not an image',
    }
  }

  // return original for gifs, svgs or no params
  if (
    ContentType === 'image/gif' ||
    ContentType === 'image/svg+xml' ||
    (resize === undefined && crop === undefined)
  ) {
    const obj = await s3.getObject(options).promise()
    const body = (obj.Body as Buffer).toString('base64')
    return base64Response(body, ContentType!, ContentDisposition!)
  }

  const s3Resp = await s3.getObject(options).promise()
  const stream = sharp(s3Resp.Body)

  try {
    const config = getConfig({ resize, crop })

    stream.limitInputPixels(false)

    if (config.crop) {
      stream.extract({
        left: config.crop.x,
        top: config.crop.y,
        width: config.crop.width,
        height: config.crop.height,
      })
    }

    if (config.resize) {
      stream.rotate()
      stream.resize(config.resize.width, config.resize.height)

      if (config.resize.force) {
        stream.ignoreAspectRatio()
      } else {
//.........这里部分代码省略.........
开发者ID:morristech,项目名称:serverless-image-proxy,代码行数:101,代码来源:handler.ts


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