Skip to main content

GraphQL API

u22a8 provides a GraphQL API powered by Apollo Server. This guide explains how to use and extend the GraphQL API.

Overview​

The GraphQL API is available at /api/graphql and provides:

  • Type-safe queries and mutations - Full GraphQL schema with TypeScript types
  • Authentication integration - Session handling via WorkOS AuthKit
  • Authorization support - Permission slugs read from the signed access token
  • Introspection - Full schema introspection in development mode

Getting Started​

Accessing the API​

The GraphQL endpoint is available at /api/graphql. In development, visit this URL in your browser to access Apollo Sandbox for interactive queries.

Schema Location​

GraphQL schemas are defined in .graphql files located at:

  • packages/shared-graphql/src/schemas/schema.graphql - Base types
  • packages/shared-graphql/src/schemas/user/schema.graphql - User domain
  • packages/shared-graphql/src/schemas/org/schema.graphql - Organization domain
  • packages/shared-graphql/src/schemas/keys/schema.graphql - API key domain
  • packages/shared-graphql/src/schemas/training/schema.graphql - a8 training data domain

Apollo Client​

The app includes Apollo Client configured for use in React components. See apps/web/src/lib/apollo/ for the client configuration.

Available Operations​

Queries​

QueryDescriptionAuth Required
helloTest queryNo
meCurrent user's auth infoNo
profile(authUserId)Get profile by auth user IDYes
viewerCurrent user, organization, and permissionsYes

Mutations​

MutationDescriptionAuth Required
updateUser(input)Update your own profileYes
completeOnboarding(input)Finish onboardingYes
addOrganizationMember(organizationId, input)Add organization memberYes (admin/owner)

Schema Types​

See the Schema Reference for complete type definitions, or explore the schemas directly in packages/shared-graphql/src/schemas/.