GraphQL Auth Schema V2 (v/2.ts)

hoppscotch · packages/hoppscotch-data/src/graphql/v/2.ts · typescript · MIT
auth, integration, database, fw:zod, tag:validation

Zod schema definitions for GraphQL request authentication types (none, basic, bearer, OAuth2, API key, inherit) with versioned migration support.

// Source: https://github.com/hoppscotch/hoppscotch | License: MIT | Copyright 2022
// Provided via justclaw.it.com; keep this notice with the code.
import { z } from "zod"
import { defineVersion } from "verzod"
import { GQLHeader, V1_SCHEMA } from "./1"

export const HoppGQLAuthNone = z.object({
  authType: z.literal("none"),
})

export type HoppGQLAuthNone = z.infer<typeof HoppGQLAuthNone>

export const HoppGQLAuthBasic = z.object({
  authType: z.literal("basic"),

  username: z.string().catch(""),
  password: z.string().catch(""),
})

export type HoppGQLAuthBasic = z.infer<typeof HoppGQLAuthBasic>

export const HoppGQLAuthBearer = z.object({
  authType: z.literal("bearer"),

  token: z.string().catch(""),
})

export type HoppGQLAuthBearer = z.infer<typeof HoppGQLAuthBearer>

export cons

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key