Socket
Book a DemoInstallSign in
Socket

garph

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

garph

A tRPC-like schema-builder for GraphQL

latest
Source
npmnpm
Version
0.6.8
Version published
Maintainers
1
Created
Source

garph

https://user-images.githubusercontent.com/10400064/222474710-bc263775-06b8-4a78-8099-676a9ad3c7a4.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

  • Install the dependencies

    npm i garph graphql-yoga
    
  • 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')
    })
    
  • Start the server

    npx ts-node server.ts
    
  • 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

FAQs

Package last updated on 25 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts