Garph

Fullstack GraphQL Framework for TypeScript
GitHub
1.31k
Created 2 years ago, last commit 9 months ago
5 contributors
213 commits
Stars added on GitHub, month by month
11
12
1
2
3
4
5
6
7
8
9
10
2023
2024
Stars added on GitHub, per day, on average
Yesterday
=
Last week
0.0
/day
Last month
+0.1
/day
Last 12 months
+0.2
/day
npmPackage on NPM
garph
0.6.8
Monthly downloads on NPM
11
12
1
2
3
4
5
6
7
8
9
10
2023
2024
README

garph

Screen.Recording.2023-02-27.at.19.32.45.mov

Warning: We would love to hear your Feedback in our Discord

Note: tRPC-style client for Garph has arrived! See garph-gqty for more 🚀

Garph is a fullstack GraphQL framework for TypeScript, that aims to deliver the best GraphQL Developer-Experience.

Get started

  1. Install the dependencies

    npm i garph graphql-yoga
    
  2. Create example GraphQL API

    import { g, InferResolvers, buildSchema } from 'garph'
    import { createYoga } from 'graphql-yoga'
    import { createServer } from 'http'
    
    const queryType = g.type('Query', {
      greet: g.string()
        .args({
          name: g.string().optional().default('Max')
        })
        .description('Greets a person')
    })
    
    const resolvers: InferResolvers<{ Query: typeof queryType }, {}> = {
      Query: {
        greet: (parent, args, context, info) => `Hello, ${args.name}`
      }
    }
    
    const schema = buildSchema({ g, resolvers })
    const yoga = createYoga({ schema })
    const server = createServer(yoga)
    server.listen(4000, () => {
      console.info('Server is running on http://localhost:4000/graphql')
    })
  3. Start the server

    npx ts-node server.ts
    
  4. Query the API

    Go to: http://localhost:4000/graphl

    Enter the following query:

    {
      greet(name: "Max")
    }

    Click on the play button

Documentation

Documentation is available on garph.dev/docs

Examples

Example projects can be found under examples/

Feedback

We would love to hear your Feedback in our Discord community