# Design URL: /docs/design Design overview for Pothos ## Type System [#type-system] The type system that powers most of the Pothos type checking has 2 components. The first is the SchemaTypes type param passed into the SchemaBuilder. This allows a shared set of types to be reused throughout the schema, and is responsible for providing type information for shared types like the [Context](./guide/context) object, and any Object, Interface, or Scalar types that you want to reference by name (as a string). Having all type information in a single object can be convenient at times, but with large schemas, can become unwieldy. To support a number of additional use cases, including Unions and Enums, large schemas, and plugins that extract type information from other sources (eg the Prisma, or the simple-objects plugin), Pothos has another way of passing around type information. This system uses `Ref` objects whose TypeScript types carry the backing shapes they represent. Every builder method for creating a type or a field returns a `Ref` object. Using Ref objects allows us to separate the type information from the implementation, and allows for a more modular design. For example, `builder.objectRef<{ id: string }>('User')` declares the backing shape before fields are defined with `implement`. The ref carries that shape at compile time and identifies the GraphQL type at runtime; it does not validate resolver values at runtime. See [Objects](./guide/objects) and [Circular References](./guide/circular-references) for examples. # Overview URL: /docs Build type-safe GraphQL schemas in TypeScript. Pothos Pothos is a GraphQL schema builder for TypeScript. You define types, fields, and resolvers in TypeScript, and Pothos checks how they fit together without generating resolver types or maintaining a separate schema definition. `builder.toSchema()` creates a standard graphql-js `GraphQLSchema` that you can pass to your GraphQL server. The core package has `graphql` as its only peer dependency. Plugins add features such as authorization, pagination, and ORM integration to the same builder. ## Build a schema from your data [#build-a-schema-from-your-data] ```typescript import SchemaBuilder from '@pothos/core'; const builder = new SchemaBuilder({}); const Giraffe = builder.objectRef<{ name: string; heightInMeters: number }>('Giraffe').implement({ fields: (t) => ({ name: t.exposeString('name'), heightInFeet: t.float({ resolve: (giraffe) => giraffe.heightInMeters * 3.28084, }), }), }); builder.queryType({ fields: (t) => ({ giraffe: t.field({ type: Giraffe, resolve: () => ({ name: 'Gina', heightInMeters: 5 }), }), }), }); export const schema = builder.toSchema(); ``` The backing data and the GraphQL type can have different shapes. Here, the resolver returns a height in meters, while clients query `heightInFeet`. Pothos checks the data returned by `giraffe` and infers the `giraffe` parameter's type in the field resolver. Follow the [Guide](/docs/guide) to install Pothos, start a server, and run your first query. [Objects](/docs/guide/objects) explains object references, classes, and registering backing types by name. The [API reference](/docs/api/schema-builder) lists the builder's methods and options. ## Plugins that make Pothos even better [#plugins-that-make-pothos-even-better] # LLM Integration URL: /docs/llms Read the Pothos documentation as plain text for use with LLMs and other tools. The documentation is also available as plain text. Use the index to find a topic, fetch an individual page, or download the complete documentation. ## Documentation index [#documentation-index] [`/llms.txt`](/llms.txt) lists each page's title, description, and link to its plain-text version. ## Full Documentation [#full-documentation] [`/llms-full.txt`](/llms-full.txt) combines all documentation pages into one response. Each page includes its title, URL, description, and processed content. ## Individual Pages [#individual-pages] Append `.mdx` to a documentation URL to read that page as text. For example, [`/docs/guide/objects.mdx`](/docs/guide/objects.mdx) contains the Objects guide. Despite the `.mdx` URL suffix, these responses contain processed documentation text, rather than the original source file with its component imports. # Resources URL: /docs/resources External guides, tools, and libraries created by members of the Pothos community. ## Guides and Tutorials [#guides-and-tutorials] * [End-To-End Type-Safety with GraphQL, Prisma & React: GraphQL API](https://www.prisma.io/blog/e2e-type-safety-graphql-react-3-fbV2ZVIGWg#start-up-a-graphql-server) by [Sabin Adams](https://twitter.com/sabinthedev) * [Code-first GraphQL with Pothos](https://graphql.wtf/episodes/60-code-first-graphql-with-pothos) by [Jamie Barton](https://twitter.com/notrab) * [Type-safe GraphQL Server with Pothos](https://omkarkulkarni.hashnode.dev/type-safe-graphql-server-with-pothos-formerly-giraphql) by [Omkar Kulkarni](https://twitter.com/omkar_k45) * [Build a GraphQL server running on Cloudflare Workers](https://the-guild.dev/blog/graphql-yoga-worker) by [Rito Tamata](https://twitter.com/chimame_rt) ## Third-party tools and libraries [#third-party-tools-and-libraries] * [Prisma Generator Pothos Codegen](https://github.com/Cauen/prisma-generator-pothos-codegen) by [Emanuel](https://twitter.com/cauenor) * [Nexus to Pothos codemod](https://github.com/villesau/nexus-to-pothos-codemod) by [Ville Saukkonen](https://twitter.com/SaukkonenVille) * [protoc-gen-pothos](https://github.com/proto-graphql/proto-graphql-js/tree/main/packages/protoc-gen-pothos) by [Masayuki Izumi](https://twitter.com/izumin5210) * [@smatch-corp/nestjs-pothos](https://github.com/smatch-corp/nestjs-pothos) by [Chanhee Lee](https://github.com/iamchanii) * [pothos-protoc-gen](https://iamchanii.github.io/pothos-protoc-gen/) by [Chanhee Lee](https://github.com/iamchanii) * [rumble](https://github.com/m1212e/rumble) (GraphQL + Drizzle + Abilities) by [m1212e](https://github.com/m1212e) [(introduction)](https://github.com/hayes/pothos/discussions/1414) ## Templates and Examples [#templates-and-examples] * [Server Template with Pothos](https://github.com/nkzw-tech/server-template) by [Nakazawa Tech](https://nakazawa.tech) * [Pothos GraphQL Server](https://github.com/theogravity/graphql-pothos-server-example) by [Theo Gravity](https://github.com/theogravity) * [GraphQL countries server](https://github.com/gbicou/countries-server) by [Benjamin VIELLARD](https://github.com/gbicou) * [datalake-graphql-wrapper](https://github.com/dbsystel/datalake-graphql-wrapper) by [noxify](https://github.com/noxify) ## Conference talks [#conference-talks] * [Pothos + Prisma: delightful, type-safe and efficient GraphQL](https://www.youtube.com/watch?v=LqKPfMmxFxw) by [Michael Hayes](https://twitter.com/yavascript) * [Building Scalable Applications](https://www.youtube.com/watch?v=rxPTEko8J7c\&t=36s) by [Christoph Nakazawa](https://cpojer.net) ## Paid tools [#paid-tools] * [Bedrock](https://bedrock.mxstbr.com/) by [Max Stoiber](https://twitter.com/mxstbr) * [nytro](https://www.nytro.dev/) by Jordan Gensler # Sponsors URL: /docs/sponsors The generous people supporting Pothos development Pothos development is supported by [sponsorships](https://github.com/sponsors/hayes) from these generous people and organizations: * The Guild * Prisma * GitHub * Stellate * [@saevarb](https://github.com/saevarb) * [@seanaye](https://github.com/seanaye) * [@arimgibson](https://github.com/arimgibson) * [@ccfiel](https://github.com/ccfiel) * [@JoviDeCroock](https://github.com/JoviDeCroock) * [@hellopivot](https://github.com/hellopivot) * [@robmcguinness](https://github.com/robmcguinness) * [@Gomah](https://github.com/Gomah) * IPS Hosting * [@garth](https://github.com/garth) * [@lifedup](https://github.com/lifedup) * [@skworden](https://github.com/skworden) * [@jacobgmathew](https://github.com/jacobgmathew) * [@aniravi24](https://github.com/aniravi24) * [@mizdra](https://github.com/mizdra) * [@3nk1du](https://github.com/3nk1du) * [@FarazPatankar](https://github.com/FarazPatankar) * [@noxify](https://github.com/noxify) * [@matthawk60](https://github.com/matthawk60) * [@BitPhinix](https://github.com/BitPhinix) * [@nathanchapman](https://github.com/nathanchapman) * [@pradyuman](https://github.com/pradyuman) * [@tmm](https://github.com/tmm)