Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaiste/graphism
Quickly create GraphQL servers in Deno & Deno Deploy
https://github.com/zaiste/graphism
deno graphql graphql-server javascript typescript
Last synced: 4 months ago
JSON representation
Quickly create GraphQL servers in Deno & Deno Deploy
- Host: GitHub
- URL: https://github.com/zaiste/graphism
- Owner: zaiste
- Created: 2022-09-25T09:27:41.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-28T16:01:49.000Z (about 2 years ago)
- Last Synced: 2024-09-28T21:43:12.455Z (4 months ago)
- Topics: deno, graphql, graphql-server, javascript, typescript
- Language: TypeScript
- Homepage:
- Size: 10.7 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Graphism
*Graphism* is a library for creating GraphQL servers in Deno & Deno Deploy.
- compatible with GraphQL.js 16.6.0
- out of the box GraphiQL
- support for GraphQL JIT```tsx
import { serve } from 'wren';
import { GET } from 'wren/route.ts';
import * as Response from 'wren/response.ts';
import { GraphQL } from 'graphism';
import SchemaBuilder from 'pothos';const builder = new SchemaBuilder({});
builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string(),
},
resolve: (_parent, { name }) => `Hello, ${name || 'World'}`,
}),
}),
});const schema = builder.toSchema();
const routes = [
GET('/', () => Response.OK('Graphism')),
GraphQL("/graphql", schema)
];serve(routes, { port: 3000 });
```## Getting Started
### Generate a Wren project
```sh
deno run -A -r https://wren.deno.dev my-graphql-server
```### Add Graphism & (optionally) Pothos
In `import_map.json` add `graphql`, `graphism` and `pothos` as dependencies:
```json
{
"imports": {
// ...
"graphql": "https://esm.sh/[email protected]",
"graphism": "https://deno.land/x/[email protected]/mod.ts",
"pothos": "https://esm.sh/@pothos/[email protected]"
}
}
```### Build the GraphQL Schema
```tsx
const builder = new SchemaBuilder({});builder.queryType({
fields: (t) => ({
hello: t.string({
args: {
name: t.arg.string(),
},
resolve: (_parent, { name }) => `Hello, ${name || 'World'}`,
}),
}),
});const schema = builder.toSchema();
```### Add the GraphQL route
```tsx
const routes = [
GET('/', () => Response.OK('Graphism')),
GraphQL("/graphql", schema)
];serve(routes, { port: 3000 });
```### Start the server
```
deno task start
```