Making Typescript + GraphQL a pleasant experience

Overview

tsgql

Making Typescript and GraphQL a pleasant experience.

What is this?

tsgql is an experimental GraphQL code generator that takes a different approach, instead of generating types from your GraphQL schema, you define your Typescript types first and use that to generate the schema.

This allows you to use the flexibility and expressiveness of Typescript's type system to create GraphQL schemas and reduce boilerplate, unlike alternatives such as type-graphql, which force you to use clunky and cumbersome classes/decorators.

It allows you to do things like this:

export type User = {
  id: string;
  name: string;
  age: number;
};

export type Mutation = {
  updateUser: (args: { id: User['id'], fields: Partial<Omit<User, 'id'>> }) => Promise<User>
}

Which generates the following GraphQL schema:

type User {
  id: String!
  name: String!
  age: Int!
}

input UpdateUserInputFields {
  name: String
  age: Int
}

type Mutation {
  updateUser(id: String!, fields: UpdateUserInputFields!): User!
}

Check out the examples folder for sample usage.

Read more here.

How it works

tsgql uses SWC to parse your Typescript schema into an AST, which is then walked and used to generate a GraphQL schema with apollo-encoder.

Before the SWC step, we run your Typescript types through the TS Compiler API, which reduces them into a simpler form. This is necessary because SWC provides no such type system utilities.

This is an experimental internal tool we use at Modfy, and is subject to breaking changes and general instability.

You might also like...
The Graph is a protocol for building decentralized applications (dApps) quickly on Ethereum and IPFS using GraphQL.

Graph Node The Graph is a protocol for building decentralized applications (dApps) quickly on Ethereum and IPFS using GraphQL. Graph Node is an open s

A Rust GraphQL system with full support for subscriptions and authentication that works out of the box.

Diana is a GraphQL system for Rust that's designed to work as simply as possible out of the box, without sacrificing configuration ability.

The purpose of this example is to provide details as to how one would go about using GraphQL with the Rust Language.

Zero to GraphQL Using Rust The purpose of this example is to provide details as to how one would go about using GraphQL with the Rust Language. Thus,

This is my painful experience trying to use sensors in Rapier2D and NPhysics

Sensor-Pain This is my painful experience trying to use sensors in Rapier2D and NPhysics. We're using a sensor on the player box to detect if the play

Aya is an eBPF library for the Rust programming language, built with a focus on developer experience and operability.

Aya API docs | Chat | Aya-Related Projects Overview eBPF is a technology that allows running user-supplied programs inside the Linux kernel. For more

Scratch-Containerised Rust GraphQL-API using Dataloaders

Dockerize Graphql Rust More current version at https://github.com/jayy-lmao/rust-cult-graphql-server This project is currently for demonstrating the u

A Rust Boilerplate server with GraphQL API, Diesel, PostgreSQL, session authentication and JWT
A Rust Boilerplate server with GraphQL API, Diesel, PostgreSQL, session authentication and JWT

Canduma rust Graphql A Rust authentication server with GraphQL API, Diesel, PostgreSQL session authentication and JWT This repository contains a Graph

An open source artifact manager. Written in Rust back end and an Vue front end to create a fast and modern experience

nitro_repo Nitro Repo is an open source free artifact manager. Written with a Rust back end and a Vue front end to create a fast and modern experience

Ref Arch: Serverless GraphQL in Rust on AWS
Ref Arch: Serverless GraphQL in Rust on AWS

A Whole Hog Reference Architecture for an Apollo Federation-Ready, Serverless, Rust-Based GraphQL Microservice on AWS using Cloud Development Kit (CDK)

This is an experiment in designing a distributed connected garden experience.

This is an experiment in designing a distributed connected garden experience. It started as an implementation of a blockchain, but has moved on to be a bit more than that. There is no proof of work like a cryptocurrency, but plays with the idea of a distributed consensus-building system.

SubZero - a standalone web server that turns your database directly into a REST/GraphQL api

What is this? This is a demo repository for the new subzero codebase implemented in Rust. subZero is a standalone web server that turns your database

Create, open, manage your Python projects with ease, a project aimed to make python development experience a little better
Create, open, manage your Python projects with ease, a project aimed to make python development experience a little better

Create, open, manage your Python projects with ease, a project aimed to make python development experience a little better

Toolbx Tuner is a tool to improve the experience with toolbx.
Toolbx Tuner is a tool to improve the experience with toolbx.

Tuner Toolbx Tuner is a tool to improve the experience with toolbx. Project Roadmap The project is currently only a user-interface concept. The

MetaCall: The ultimate polyglot programming experience.
MetaCall: The ultimate polyglot programming experience.

MetaCall Polyglot Runtime MetaCall.io | Install | Docs MetaCall allows calling functions, methods or procedures between multiple programming languages

Type-safe IPC for Tauri using GraphQL

Tauri Plugin graphql A plugin for Tauri that enables type-safe IPC through GraphQL. Install Rust [dependencies] tauri-plugin-graphql = "0.2" JavaScrip

Ecstasy - a subjective experience of total involvement of the subject, with an object of their awareness.

Ecstasy (from Ancient Greek ἔκστασις ékstasis, meaning 'outside of oneself') is a subjective experience of total involvement of the subject, with an object of their awareness. In classical Greek literature it refers to removal of the mind or body "from its normal place of function."

Examples of how to use Rust with Serverless Framework, Lambda, API Gateway v1 and v2, SQS, GraphQL, etc

Rust Serverless Examples All examples live in their own directories: project: there is nothing here, just a simple cargo new project_name with a custo

Bracket QOS - a Quality of Service/Experience server system writtin in Rust. Derived from the excellent LibreQOS Project.

Bracket QOS - Open Source Edition This project is based on the excellent LibreQOS project. It is hoped that this can be useful for the upstream projec

SimConnect SDK in Rust. An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience.

SimConnect SDK An opinionated SimConnect Client that encapsulates the C API fully and optimizes for developer experience. Usage [dependencies] simconn

Owner
Modfy
Organization responsible for building modfy.video
Modfy
An implementation of the classic arcade game Whac-A-Hole inside Discord, made in 12 hours, with no experience in Rust.

Whac-A-Hole A blazingly fast implementation of the classic arcade game What-A-Hole inside Discord, made in 12 hours, with no experience in Rust ( ?? ?

Face 6 Mar 20, 2023
Altruistic Angelshark is a project devoted to making Communication Manager (ACM) automation easier.

This project makes automating over one or more Communication Managers easier via OSSI over SSH.

ADP, LLC. 3 Feb 13, 2022
Rust-based static analysis for TypeScript projects

Fast TypeScript Analyzer FTA (Fast TypeScript Analyzer) is a super-fast TypeScript static analysis tool written in Rust. It captures static informatio

Sam Brown 4 May 23, 2023
A Rust SQL query builder with a pleasant fluent API closely imitating actual SQL

Scooby An SQL query builder with a pleasant fluent API closely imitating actual SQL. Meant to comfortably build dynamic queries with a little bit of s

Aleksei Voronov 100 Nov 11, 2022
Rust / Hasura / GraphQL

Rust + Hasura This is an example of a Rust server that functions as a remote schema for Hasura. It demonstrates: user login + signup JWT authorization

Rónán 130 Dec 26, 2022
A GraphQL server library implemented in Rust

A GraphQL server library implemented in Rust Async-graphql is a high-performance server-side library that supports all GraphQL specifications. Feature

null 2.6k Jan 8, 2023
Typed, correct GraphQL requests and responses in Rust

graphql_client A typed GraphQL client library for Rust. Features Precise types for query variables and responses. Supports GraphQL fragments, objects,

GraphQL Rust 914 Dec 27, 2022
GraphQL server library for Rust

GraphQL server library for Rust GraphQL is a data query language developed by Facebook intended to serve mobile and web application frontends. Juniper

GraphQL Rust 4.9k Jan 5, 2023
Diana is a GraphQL system for Rust that's designed to work as simply as possible out of the box

Diana is a GraphQL system for Rust that's designed to work as simply as possible out of the box, without sacrificing configuration ability. Unlike other GraphQL systems, Diana fully supports serverless functions and automatically integrates them with a serverful subscriptions system as needed, and over an authenticated channel. GraphQL subscriptions are stateful, and so have to be run in a serverful way. Diana makes this process as simple as possible.

null 0 Aug 3, 2021
Better GNOME Desktop Experience

Better GNOME Desktop Experience Tired of having the best feeling DE with the worst defaults? This app is for you. Transform the default GNOME look to:

Dimitar Dimitrov 3 May 10, 2022