(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5405],{9424:function(s,e,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return n(8337)}])},8337:function(s,e,n){"use strict";n.r(e),n.d(e,{__N_SSG:function(){return a},frontmatter:function(){return t}});var r=n(5250),l=n(7160),i=n(3210),a=!0;let t={title:"Pothos GraphQL Overview and documentation",name:"Overview",description:"Pothos - A plugin based GraphQL schema builder for typescript",link:"/"},h=i.k;function o(s){let e=Object.assign({p:"p",img:"img",h1:"h1",code:"code",h2:"h2",pre:"pre",span:"span",ul:"ul",li:"li",a:"a",strong:"strong"},(0,l.ah)(),s.components);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e.p,{children:(0,r.jsx)(e.img,{src:"https://pothos-graphql.dev/assets/logo-name-auto.svg",alt:"Pothos"})}),"\n",(0,r.jsx)(e.h1,{id:"pothos-graphql",children:"Pothos GraphQL"}),"\n",(0,r.jsx)(e.p,{children:"Pothos is a plugin based GraphQL schema builder for typescript."}),"\n",(0,r.jsxs)(e.p,{children:["It makes building graphql schemas in typescript easy, fast and enjoyable. The core of Pothos adds 0\noverhead at runtime, and has ",(0,r.jsx)(e.code,{children:"graphql"})," as its only dependency."]}),"\n",(0,r.jsx)(e.p,{children:"Pothos is the most type-safe way to build GraphQL schemas in typescript, and by leveraging type\ninference and typescript's powerful type system Pothos requires very few manual type definitions and\nno code generation."}),"\n",(0,r.jsx)(e.p,{children:"Pothos has a unique and powerful plugin system that makes every plugin feel like its features are\nbuilt into the core library. Plugins can extend almost any part of the API by adding new options or\nmethods that can take full advantage of the Pothos type system."}),"\n",(0,r.jsx)(e.h2,{id:"hello-world",children:"Hello, World"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsxs)(e.code,{className:"hljs language-typescript",children:[(0,r.jsx)(e.span,{className:"hljs-keyword",children:"import"})," { createYoga } ",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"from"})," ",(0,r.jsx)(e.span,{className:"hljs-string",children:"'graphql-yoga'"}),";\n",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"import"})," { createServer } ",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"from"})," ",(0,r.jsx)(e.span,{className:"hljs-string",children:"'node:http'"}),";\n",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"import"})," ",(0,r.jsx)(e.span,{className:"hljs-title class_",children:"SchemaBuilder"})," ",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"from"})," ",(0,r.jsx)(e.span,{className:"hljs-string",children:"'@pothos/core'"}),";\n\n",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"const"})," builder = ",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"new"})," ",(0,r.jsx)(e.span,{className:"hljs-title class_",children:"SchemaBuilder"}),"({});\n\nbuilder.",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"queryType"}),"({\n  ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"fields"}),": ",(0,r.jsxs)(e.span,{className:"hljs-function",children:["(",(0,r.jsx)(e.span,{className:"hljs-params",children:"t"}),") =>"]})," ({\n    ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"hello"}),": t.",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"string"}),"({\n      ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"args"}),": {\n        ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"name"}),": t.",(0,r.jsx)(e.span,{className:"hljs-property",children:"arg"}),".",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"string"}),"(),\n      },\n      ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"resolve"}),": ",(0,r.jsxs)(e.span,{className:"hljs-function",children:["(",(0,r.jsx)(e.span,{className:"hljs-params",children:"parent, { name }"}),") =>"]})," ",(0,r.jsxs)(e.span,{className:"hljs-string",children:["`hello, ",(0,r.jsxs)(e.span,{className:"hljs-subst",children:["${name || ",(0,r.jsx)(e.span,{className:"hljs-string",children:"'World'"}),"}"]}),"`"]}),",\n    }),\n  }),\n});\n\n",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"const"})," yoga = ",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"createYoga"}),"({\n  ",(0,r.jsx)(e.span,{className:"hljs-attr",children:"schema"}),": builder.",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"toSchema"}),"(),\n});\n\n",(0,r.jsx)(e.span,{className:"hljs-keyword",children:"const"})," server = ",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"createServer"}),"(yoga);\n\nserver.",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"listen"}),"(",(0,r.jsx)(e.span,{className:"hljs-number",children:"3000"}),", ",(0,r.jsx)(e.span,{className:"hljs-function",children:"() =>"})," {\n  ",(0,r.jsx)(e.span,{className:"hljs-variable language_",children:"console"}),".",(0,r.jsx)(e.span,{className:"hljs-title function_",children:"log"}),"(",(0,r.jsx)(e.span,{className:"hljs-string",children:"'Visit http://localhost:3000/graphql'"}),");\n});\n"]})}),"\n",(0,r.jsx)(e.h2,{id:"what-sets-pothos-apart",children:"What sets Pothos apart"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsx)(e.li,{children:"Pothos was built from the start to leverage typescript for best-in-class type-safety."}),"\n",(0,r.jsx)(e.li,{children:"Pothos has a clear separation between the shape of your external GraphQL API, and the internal\nrepresentation of your data."}),"\n",(0,r.jsx)(e.li,{children:"Pothos comes with a large plugin ecosystem that provides a wide variety of features while\nmaintaining great interoperability between plugins."}),"\n",(0,r.jsx)(e.li,{children:"Pothos does not depend on code-generation or experimental decorators for type-safety."}),"\n",(0,r.jsx)(e.li,{children:"Pothos has been designed to work at every scale from small prototypes to huge Enterprise\napplications, and is in use at some of the largest tech companies including Airbnb and Netflix."}),"\n"]}),"\n",(0,r.jsx)(e.h2,{id:"plugins-that-make-pothos-even-better",children:"Plugins that make Pothos even better"}),"\n",(0,r.jsxs)(e.ul,{children:["\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/add-graphql",children:(0,r.jsx)(e.strong,{children:"Add GraphQL"})})}),"\n",(0,r.jsx)(e.p,{children:"Add existing GraphQL types to your schema"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/scope-auth",children:(0,r.jsx)(e.strong,{children:"Auth"})})}),"\n",(0,r.jsx)(e.p,{children:"Add global, type level, or field level authorization checks to your schema"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/complexity",children:(0,r.jsx)(e.strong,{children:"Complexity"})})}),"\n",(0,r.jsx)(e.p,{children:"A plugin for defining and limiting complexity of queries"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/directives",children:(0,r.jsx)(e.strong,{children:"Directives"})})}),"\n",(0,r.jsx)(e.p,{children:"Integrate with existing schema graphql directives in a type-safe way."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/errors",children:(0,r.jsx)(e.strong,{children:"Errors"})})}),"\n",(0,r.jsx)(e.p,{children:"A plugin for easily including error types in your GraphQL schema and hooking up error types to\nresolvers."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/dataloader",children:(0,r.jsx)(e.strong,{children:"Dataloader"})})}),"\n",(0,r.jsx)(e.p,{children:"Quickly define data-loaders for your types and fields to avoid n+1 queries."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/mocks",children:(0,r.jsx)(e.strong,{children:"Mocks"})})}),"\n",(0,r.jsx)(e.p,{children:"Add mock resolvers for easier testing"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/prisma",children:(0,r.jsx)(e.strong,{children:"Prisma"})})}),"\n",(0,r.jsx)(e.p,{children:"A plugin for more efficient integration with prisma that can help solve n+1 issues and more\nefficiently resolve queries"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/relay",children:(0,r.jsx)(e.strong,{children:"Relay"})})}),"\n",(0,r.jsx)(e.p,{children:"Easy to use builder methods for defining relay style nodes and connections, and helpful utilities\nfor cursor based pagination."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/simple-objects",children:(0,r.jsx)(e.strong,{children:"Simple Objects"})})}),"\n",(0,r.jsx)(e.p,{children:"Define simple object types without resolvers or manual type definitions."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/smart-subscriptions",children:(0,r.jsx)(e.strong,{children:"Smart Subscriptions"})})}),"\n",(0,r.jsx)(e.p,{children:"Make any part of your graph subscribable to get live updates as your data changes."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/sub-graph",children:(0,r.jsx)(e.strong,{children:"Sub-Graph"})})}),"\n",(0,r.jsx)(e.p,{children:"Build multiple subsets of your graph to easily share code between internal and external APIs."}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/tracing",children:(0,r.jsx)(e.strong,{children:"Tracing"})})}),"\n",(0,r.jsx)(e.p,{children:"Add tracing for resolver execution, with support for opentelemetry, newrelic, century, logging,\nand custom tracers"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/validation",children:(0,r.jsx)(e.strong,{children:"Validation"})})}),"\n",(0,r.jsx)(e.p,{children:"Validating your inputs and arguments"}),"\n"]}),"\n",(0,r.jsxs)(e.li,{children:["\n",(0,r.jsx)(e.p,{children:(0,r.jsx)(e.a,{href:"https://pothos-graphql.dev/docs/plugins/with-input",children:(0,r.jsx)(e.strong,{children:"With-Input"})})}),"\n",(0,r.jsx)(e.p,{children:"Define fields with inline input objects"}),"\n"]}),"\n"]})]})}e.default=function(){let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,r.jsx)(h,Object.assign({},s,{children:(0,r.jsx)(o,s)}))}}},function(s){s.O(0,[8430,3210,9774,2888,179],function(){return s(s.s=9424)}),_N_E=s.O()}]);