// @bun
import{CodeBlock as r,InstallCommand as o}from"@contractspec/lib.design-system";import a from"@contractspec/lib.ui-link";import{ChevronRight as i}from"lucide-react";import{jsx as e,jsxs as t}from"react/jsx-runtime";function n(){return t("div",{className:"space-y-8",children:[t("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"GraphQL Libraries"}),e("p",{className:"text-muted-foreground",children:"This suite of libraries enables seamless GraphQL integration, transforming your ContractSpecs into a type-safe Pothos schema, connecting with Prisma, and enabling Apollo Federation."})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Libraries"}),t("div",{className:"grid gap-4 md:grid-cols-1",children:[t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.graphql-core"}),e("p",{className:"mt-2 text-muted-foreground text-sm",children:"The foundation. Provides a configured Pothos builder, common scalars (JSON, DateTime), and utilities for mapping ContractSpec I/O to Pothos types."})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.graphql-prisma"}),e("p",{className:"mt-2 text-muted-foreground text-sm",children:"Connects Pothos to Prisma. Automatically generates GraphQL types from your Prisma schema and optimizes queries to prevent N+1 issues."})]}),t("div",{className:"card-subtle p-6",children:[e("h3",{className:"font-bold text-lg",children:"@contractspec/lib.graphql-federation"}),e("p",{className:"mt-2 text-muted-foreground text-sm",children:"Adds Apollo Federation V2 support. Allows your subgraph to define keys and entities, making it ready for a supergraph."})]})]})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(o,{package:["@contractspec/lib.graphql-core","@contractspec/lib.graphql-prisma","@contractspec/lib.graphql-federation"]})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Usage: Building a Schema"}),e("p",{className:"text-muted-foreground",children:"Here's how to assemble a federated GraphQL schema from your specs:"}),e(r,{language:"typescript",code:`import { builder } from '@contractspec/lib.graphql-core';
import { registerContractsOnBuilder } from '@contractspec/lib.contracts-runtime-server-graphql/graphql-pothos';
import { OperationSpecRegistry } from '@contractspec/lib.contracts-spec';
import { MySpecs } from './specs';

// 1. Register contracts
const registry = new OperationSpecRegistry();
registry.register(MySpecs);

// 2. Mount specs onto Pothos builder
registerContractsOnBuilder(builder, registry);

// 3. Build and print schema
const schema = builder.toSchema();
console.log(printSchema(schema));`})]}),t("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Features"}),t("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[t("li",{children:[e("strong",{children:"Code-First"}),": Define schema in TypeScript (Pothos), get SDL as artifact."]}),t("li",{children:[e("strong",{children:"Spec Integration"}),": `registerContractsOnBuilder` automatically converts Command/Query specs into Mutations/Queries."]}),t("li",{children:[e("strong",{children:"Federation Ready"}),": Just add `provider: 'federation'` to your config."]})]})]}),t("div",{className:"flex items-center gap-4 pt-4",children:[t(a,{href:"/docs/libraries/data-backend",className:"btn-primary",children:["Next: Data & Backend ",e(i,{size:16})]}),e(a,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"})]})]})}export{n as LibrariesGraphQLPage};
