- @pothos/plugin-drizzle@0.5.2Latest
- release-1731450725
- @pothos-examples/complex-app@2.1.11
- @pothos/plugin-dataloader@4.3.0
- release-1731014728
- release-1730844198
- release-1730496474
- release-1729828966
- @pothos/plugin-smart-subscriptions@4.1.1
- @pothos-examples/prisma-smart-subscriptions-apollo@3.1.5
- release-1729644476
- release-1729625041
- release-1729350586
- release-1729140192
- release-1729030130
- release-1728435798
- release-1727726265
- @pothos-examples/complex-app@2.1.5
- @pothos/plugin-dataloader@4.1.1
- release-1727414792
- release-1726524975
- @pothos/plugin-drizzle@0.4.7
- release-1726004400
- @pothos/plugin-drizzle@0.4.6
- release-1725939123
- @pothos/plugin-drizzle@0.4.5
- release-1725938372
- @pothos/plugin-drizzle@0.4.4
- release-1725931961
- release-1725906530
- @pothos/plugin-drizzle@0.4.3
- release-1725859676
- @pothos/plugin-drizzle@0.4.1
- release-1725845079
- release-1725695129
- release-1725301526
- release-1723512702
- release-1723331040
- release-1723049480
- release-1723042815
- @pothos/plugin-drizzle@0.2.1
- release-1722804314
- @pothos/plugin-drizzle@0.2.0
- release-1722803164
- release-1722578322
- @pothos/plugin-prisma-utils@1.1.1
- release-1722532905
- release-1722403874
- @pothos-examples/complex-app@2.0.8
- @pothos/plugin-prisma-utils@1.1.0
- release-1721977283
- @pothos/plugin-prisma-utils@1.0.6
- @pothos-examples/complex-app@2.0.7
- release-1721968693
- release-1721854018
- release-1721684308
- release-1721230199
- release-1721151386
- release-1721105284
- release-1720765432
- @pothos/plugin-simple-objects@4.0.1
- @pothos-examples/complex-app@2.0.2
- release-1720652677
- release-1720638912
- release-1720629208
- release-1720626976
- release-1720581889
- @pothos/plugin-dataloader@3.19.0
- @pothos-examples/complex-app@1.6.30
- release-1719780052
- release-1719071157
- release-1718861157
- release-1716310600
- @pothos/plugin-federation@3.16.0
- @pothos-examples/federation@2.8.59
- @pothos-examples/prisma-federation@2.8.61
- release-1716271365
- release-1715619867
- release-1714608850
- release-1713397530
- @pothos/plugin-authz@3.5.9
- release-1712344623
- release-1709934481
- release-1709668418
- @pothos-examples/prisma-federation@2.8.58
- @pothos/plugin-federation@3.15.0
- @pothos-examples/federation@2.8.57
- release-1709339366
- @pothos-examples/prisma-federation@2.8.57
- @pothos/plugin-federation@3.14.1
- @pothos-examples/federation@2.8.56
- release-1709331729
- @pothos-examples/prisma-federation@2.8.56
- @pothos/plugin-federation@3.14.0
- @pothos-examples/federation@2.8.55
- release-1709330086
- @pothos/plugin-dataloader@3.18.1
- @pothos-examples/complex-app@1.6.25
- release-1708848346
- @pothos-examples/complex-app@1.6.24
- @pothos/plugin-dataloader@3.18.0
- release-1708814058
- @pothos/plugin-scope-auth@3.21.1
- @pothos-examples/complex-app@1.6.23
- release-1708290547
- release-1708289977
- release-1707882703
- release-1707882089
- @pothos-examples/federation@2.8.54
- @pothos/plugin-federation@3.13.1
- @pothos-examples/prisma-federation@2.8.54
- release-1707429200
- @pothos-examples/prisma-federation@2.8.53
- @pothos/plugin-federation@3.13.0
- release-1706480661
- release-1706477084
- release-1705608848
- release-1704330761
- @pothos/plugin-federation@3.12.0
- @pothos-examples/prisma-federation@2.8.50
- release-1703632026
- release-1703191169
- release-1702680405
- release-1702497477
- release-1702415988
- release-1702326694
- release-1702250751
- @pothos-examples/complex-app@1.6.17
- @pothos/plugin-prisma-utils@0.14.0
- release-1701979514
- release-1701642408
- release-1701475439
- @pothos/plugin-dataloader@3.17.2
- @pothos-examples/complex-app@1.6.15
- @pothos/deno@3.48.1
- release-1701457624
- release-1701384241
- release-1700067354
- release-1699481559
- @pothos/plugin-prisma-utils@0.13.0
- @pothos-examples/complex-app@1.6.14
- release-1699254040
- @pothos/plugin-prisma-utils@0.12.1
- @pothos-examples/complex-app@1.6.13
- release-1698870176
- release-1698167984
- release-1696478497
- release-1696476162
- release-1696471065
- release-1695766300
- release-1695407188
- release-1695357276
- release-1695356590
- release-1695354039
- release-1695353533
- release-1695341392
- release-1695332732
- release-1695321187
- release-1695106359
- release-1695089285
- release-1694882392
- release-1694457405
- release-1694147393
- release-1694123833
- release-1693975697
- release-1693969858
- release-1693588691
- release-1693423020
- release-1693334611
- release-1691781070
- release-1691603238
- release-1691551050
- @pothos/plugin-validation@3.10.0
- @pothos-examples/complex-app@1.6.2
- release-1691520399
- release-1691509959
- release-1691259632
- release-1691256824
- release-1691190553
- release-1691034117
- release-1690784745
- release-1690733553
- release-1690306299
- release-1690266013
- release-1690237157
- release-1690221287
- release-1689883337
- release-1689881826
- release-1689659814
- release-1689262653
- release-1689095465
- @pothos/plugin-prisma-utils@0.10.0
- @pothos-examples/complex-app@1.5.20
- release-1688425816
- release-1687998954
- release-1687562713
- @pothos/plugin-prisma-utils@0.9.0
- @pothos/plugin-complexity@3.13.0
- release-1686860061
- release-1686440053
- release-1685478246
- @pothos-examples/complex-app@1.5.17
- @pothos/plugin-simple-objects@3.7.0
- release-1685145270
- release-1685121919
- release-1684268666
- release-1684232988
- release-1684230554
- @pothos/plugin-scope-auth@3.19.2
- @pothos-examples/complex-app@1.5.14
- release-1684212385
- release-1683707706
- release-1683360040
- release-1683153907
- release-1683093851
- release-1683066767
- release-1683062336
- release-1682956526
- release-1682955067
- release-1681940475
- release-1681923896
- release-1680662597
- @pothos/deno@3.41.0
- release-1680305198
- release-1680294900
- release-1680102086
- release-1680059285
- @pothos/plugin-sub-graph@3.13.1
- release-1680018074
- release-1679694176
- release-1679639962
- release-1679639557
- release-1679414233
- release-1679362172
- release-1679360299
- release-1679294618
- release-1679294370
- release-1679294181
- release-1679079302
- release-1679013515
- release-1678483878
- release-1678416008
- release-1677682669
- release-1677679515
- release-1677673768
- release-1677665905
- release-1677586493
- release-1677226060
- release-1677191465
- release-1677173079
- release-1677107395
- release-1677095806
- release-1676936502
- release-1676597138
- release-1675894222
- @pothos-examples/prisma-federation@2.7.2
- @pothos/plugin-federation@3.9.1
- release-1675794421
- release-1675793561
- release-1675746937
- release-1675655551
- release-1675561945
- release-1675388380
- release-1675124523
- release-1674854552
- release-1674768676
- release-1674597101
- release-1674546825
- release-1674369608
- release-1674365534
- release-1674364933
- release-1674229805
- @pothos-examples/prisma-smart-subscriptions-apollo@2.4.18
- release-1674088419
- release-1674064555
- release-1673993192
- release-1673469490
- release-1673464346
- @pothos/plugin-with-input@3.10.0
- release-1673061463
- release-1673058827
- release-1672693376
- release-1672693224
- release-1672691435
- release-1671837822
- release-1671236100
- release-1671046252
- release-1671038346
- release-1670972010
- release-1670470900
- release-1670453836
- release-1670368038
- release-1670354276
- release-1670106930
- release-1670106367
- release-1670043728
- release-1670043609
- release-1670043498
- release-1670043383
- release-1670043275
- release-1670043192
- release-1670042974
- @pothos/plugin-federation@3.6.0
- @pothos/plugin-directives@3.8.0
- @pothos-examples/prisma-federation@2.6.6
- @pothos/plugin-authz@3.4.1
- @pothos/plugin-prisma-utils@0.2.0
- @pothos/deno@3.24.1
- @pothos/plugin-complexity@3.9.1
- @pothos/plugin-complexity@3.9.0
- @pothos/deno@3.24.0
- @pothos/plugin-complexity@3.7.0
- @pothos/plugin-sub-graph@3.10.0
- @pothos/plugin-sub-graph@3.9.0
- @pothos/plugin-sub-graph@3.8.0
- @pothos/plugin-prisma-utils@0.1.1
- @pothos/plugin-prisma-utils@0.1.0
- @pothos/plugin-prisma-utils@0.0.0
- @pothos/plugin-validation@3.6.0
- @pothos/plugin-complexity@3.6.1
- @pothos-examples/prisma-relay@2.4.8
- @pothos-examples/relay-windowed-pagination@2.3.3
- @pothos/plugin-relay@3.18.1
- @pothos-examples/prisma-federation@2.4.8
- @pothos/plugin-prisma@3.21.1
- @pothos-examples/prisma-relay@2.4.6
- @pothos/plugin-sub-graph@3.7.0
- @pothos-examples/prisma-relay@2.4.3
- @pothos-examples/prisma-federation@2.4.5
- @pothos/plugin-prisma@3.19.0
- @pothos-examples/prisma-federation@2.4.4
- @pothos/plugin-prisma@3.18.0
- @pothos-examples/prisma-relay@2.4.2
- @pothos-examples/prisma-federation@2.4.3
- @pothos-examples/prisma-relay@2.4.1
- @pothos/plugin-prisma@3.17.0
- @pothos/plugin-prisma@3.16.0
- @pothos-examples/prisma-federation@2.4.2
- @pothos-examples/prisma-relay@2.3.1
- @pothos-examples/prisma-federation@2.4.1
- @pothos-examples/open-telemetry@1.1.0
- @pothos-examples/relay-windowed-pagination@2.2.6
- @pothos/plugin-relay@3.14.0
- @pothos-examples/prisma-federation@2.3.5
- @pothos/plugin-prisma@3.10.0
- @pothos-examples/prisma@2.3.1
- @pothos-examples/prisma-relay@2.2.1
- @pothos/plugin-prisma@3.8.0
- @pothos/tracing-xray@0.1.0
- @pothos/tracing-opentelemetry@0.2.0
- @pothos/tracing-sentry@0.3.0
- @pothos/tracing-sentry@0.2.0
- @pothos-examples/prisma@2.1.8
- @pothos/plugin-prisma@3.5.0
- @pothos-examples/prisma-relay@2.1.4
- @pothos/plugin-with-input@3.1.1
- @pothos/deno@3.6.2
- @pothos/plugin-validation@3.1.0
- @pothos/plugin-complexity@3.1.2
- @pothos/core@3.3.2
- @pothos/plugin-scope-auth@3.4.1
- @pothos/plugin-scope-auth@3.4.0
- @pothos/plugin-prisma@0.17.1
- @pothos/plugin-relay@3.5.0
- @pothos/core@3.3.0
- @pothos/plugin-scope-auth@3.2.0
- @pothos/plugin-scope-auth@3.1.0
- @pothos/plugin-scope-auth@3.0.2
- @pothos/plugin-relay@3.3.0
- @pothos/plugin-dataloader@3.2.0
- @pothos/deno@3.3.0
- @pothos/core@3.1.1
- @pothos/plugin-federation@0.2.1
- @pothos/core@3.1.0
- @pothos/plugin-directives@3.1.0
- @pothos/plugin-federation@0.2.0
- @pothos/plugin-prisma@0.16.1
- @pothos-examples/prisma@2.0.2
- @pothos-examples/prisma-relay@2.0.2
- @pothos/plugin-prisma@0.16.0
- @pothos/deno@3.2.0
- @pothos/plugin-dataloader@3.1.0
Pothos GraphQL
Pothos is a plugin based GraphQL schema builder for typescript.
It makes building graphql schemas in typescript easy, fast and enjoyable. The core of Pothos adds 0
overhead at runtime, and has graphql
as its only dependency.
Pothos is the most type-safe way to build GraphQL schemas in typescript, and by leveraging type inference and typescript’s powerful type system Pothos requires very few manual type definitions and no code generation.
Pothos has a unique and powerful plugin system that makes every plugin feel like its features are built into the core library. Plugins can extend almost any part of the API by adding new options or methods that can take full advantage of the Pothos type system.
Note on deno.land
Currently deno.land does not work well with the way versions are tagged in pothos. See instructions below for details on how to use pothos with other deno compatible CDNs!
Hello, World
import { serve } from 'https://deno.land/std@0.157.0/http/server.ts';
import { createYoga } from 'graphql-yoga';
import SchemaBuilder from '@pothos/core';
const builder = new SchemaBuilder({});
builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string({}),
},
resolve: (_, { name }) => `hello, ${name || 'World'}`,
}),
}),
});
const yoga = createYoga({
schema: builder.toSchema(),
});
serve(yoga, {
onListen({ hostname, port }) {
console.log(`Listening on http://${hostname}:${port}/graphql`);
},
});
What sets Pothos apart
- Pothos was built from the start to leverage typescript for best-in-class type-safety.
- Pothos has a clear separation between the shape of your external GraphQL API, and the internal representation of your data.
- Pothos comes with a large plugin ecosystem that provides a wide variety of features while maintain great interoperability between plugins.
- Pothos does not depend on code-generation or experimental decorators for type-safety.
- Pothos has been designed to work at every scale from small prototypes to huge Enterprise applications, and is in use at some of the largest tech companies including Airbnb and Netflix.
Plugins that make Pothos even better
-
Add global, type level, or field level authorization checks to your schema
-
A plugin for defining and limiting complexity of queries
-
Integrate with existing schema graphql directives in a type-safe way.
-
A plugin for easily including error types in your GraphQL schema and hooking up error types to resolvers.
-
Quickly define data-loaders for your types and fields to avoid n+1 queries.
-
Add mock resolvers for easier testing
-
A plugin for more efficient integration with prisma that can help solve n+1 issues and more efficienty resolve queries
-
Easy to use builder methods for defining relay style nodes and connections, and helpful utilities for cursor based pagination.
-
Define simple object types without resolvers or manual type definitions.
-
Make any part of your graph subscribable to get live updates as your data changes.
-
Build multiple subsets of your graph to easily share code between internal and external APIs.
-
Validating your inputs and arguments
Imports
There are a number of different ways to import Pothos, but the best option is ussually to set up import maps and import from esm.sh.
Import maps
// import_maps.json
{
"imports": {
// define a version of graphql, this should be shared by all graphql libraries
"graphql": "https://esm.sh/graphql@16.6.0",
// Marking graphql as external will all the graphql from this import_map to be used
"graphql-yoga": "https://esm.sh/graphql-yoga?external=graphql",
// the `*` prefix in the package name marks all depenencies (only graphql in this case) as external
// this ensures the version of graphql defined above is used
"@pothos/core": "https://esm.sh/*@pothos/core@3.23.1",
// Plugins should mark all dependencies as external as well
// this will ensure that both graphql and @pothos/core use the versions defined above
// some plugins like validation may require additional dependencies to be added to the import map (eg. zod)
"@pothos/plugin-relay": "https://esm.sh/*@pothos/plugin-relay@3.30.0"
}
}
deno.json
// deno.jsonc
{
"importMap": "import_map.json"
}
Server
// src/index.ts
import { serve } from 'https://deno.land/std@0.157.0/http/server.ts';
import { createYoga } from 'graphql-yoga';
import SchemaBuilder from '@pothos/core';
const builder = new SchemaBuilder({});
builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string({}),
},
resolve: (_, { name }) => `hello, ${name || 'World'}`,
}),
}),
});
const yoga = createYoga({
schema: builder.toSchema(),
});
serve(yoga, {
onListen({ hostname, port }) {
console.log(`Listening on http://${hostname}:${port}/graphql`);
},
});
Running the app:
deno run --allow-net src/index.ts
Without import maps
In some cases (like when using the deno deploy playground) you may not be able to use import maps. In this case, you can use query parameters with esm.sh to ensure that shared versions of packages are used:
import { serve } from 'https://deno.land/std@0.157.0/http/server.ts';
// for graphql-yoga and pothos/core 'graphql' is the most import depencency to pin
import { createYoga } from 'https://esm.sh/graphql-yoga@3.1.1?deps=graphql@16.6.0';
import SchemaBuilder from 'https://esm.sh/@pothos/core@3.23.1?deps=graphql@16.6.0';
// for pothos plugins, you should pin both 'graphql' and '@pothos/core'
import RelayPlugin from 'https://esm.sh/@pothos/plugin-relay@3.30.0?deps=graphql@16.6.0,@pothos/core@3.23.1';
The @pothos/deno package
The @pothos/deno
package contains a typescript-only version of most of the pothos plugins. This is
no longer the recommended way to use pothos with deno, but will continue to be published with new
changes.
The files for this package are published to npm, and can be consumed from a number of CDNs. The benefit of this is that all plugins are bundled with pothos/core, and import directly so you do not need to mess with dependencies to ensure that plugins are using the correct version of pothos/core.
example
// dependencies of @pothos/deno are imported from https://cdn.skypack.dev/{package} to ensure
// that the same version of 'graphql' is used, import other dependencies from sky pack as well
import { serve } from 'https://deno.land/std@0.157.0/http/server.ts';
import { createYoga } from 'https://cdn.skypack.dev/graphql-yoga@3.1.1';
import SchemaBuilder from 'https://esm.sh/@pothos/deno/packages/core/mod.ts';
import RelayPlugin from 'https://esm.sh/@pothos/deno/packages/plugin-relay/mod.ts';
Pothos uses https://cdn.skypack.dev/graphql?dts
which can be added to an import map to import a
different version of graphql.