Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@genql/cli

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@genql/cli

Generate a TypeScript SDK for any GraphQl API

  • 5.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.8K
decreased by-25.97%
Maintainers
1
Weekly downloads
 
Created
Source




Type safe Graphql query builder

Write Graphql queries with type validation and auto completion


Read the quick start guide to generate your client and start writing queries.

You can stay up to date with the latest changes subscribing to the Genql changelog.

🔥 Features

  • Type completion & Type validation
  • No dependencies
  • Easily fetch all scalar fields in a type
  • Works with any client (Apollo, Relay, etc)
  • Works in browser, Node, Deno, Cloudflare workers, Bun and more

Example

First generate your client executing

npm i -D @genql/cli # cli to generate the client code
genql --schema ./schema.graphql --output ./generated

Then you can use your client as follow

import { createClient, everything } from './generated'
const client = createClient()

client
    .query({
        countries: {
            // pass arguments to the query
            __args: {
                filter: {
                    currency: {
                        eq: 'EUR',
                    },
                },
            },
            name: true,
            code: true,
            nestedField: {
                // fetch all scalar fields
                __scalar: true,
            },
        },
    })
    .then(console.log)

The code above will fetch the graphql query below

query {
    countries(filter: { currency: { eq: "EUR" } }) {
        name
        code
        nestedField {
            scalarField1
            scalarField2
        }
    }
}

Why

Genql has a lot of benefits over other writing graphql queries by hand:

  • Writing queries is faster thanks to TypeScript auto completion
  • You can safely update your schema and be sure your queries are still valid
  • You can fetch all scalar fields in a type with __scalar: true
  • No graphql package dependency
  • You have to generate the client only after your schema changes, not after every query change

Sponsors

Notaku

Notaku

Vercel


Licensed under MIT.

Keywords

FAQs

Package last updated on 29 Apr 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc