Giter Club home page Giter Club logo

mullholland's Introduction

mullholland

A library for creating type safe graphql queries in typescript without code generation.

WORK IN PROGRESS. this is not usable in its current form.

Using graphql in typescript on the client side often involves code generation to expose compile time knowledge encoded in the graphql schema and SDL queries into types that can be used in your typescript code. Code generation complicates the build process, adds cognitive overhead, and slows down development when queries are changing.

Instead of code generation, mullholland allows you to define your queries as simple objects within your typescript code. It can transform these objects into SDL for use with any graphql client library, and the result type of the query is inferrable without any code generation, allowing for instant updates when the query changes.

Selectors

mullholland builds up queries as selectors, objects which represent a subset of your graph. Selectors are simple objects designed to look like the graphql SDL they correspond to.

# in graphql SDL
query getMullhollandUser {
  getUser(id: 'mullholland') {
    name
    location {
      zip
    }
  }
}
// in mullholland selectors
const getMullhollandUser = query({
  getUser: [{id: 'mullholland'}, {
    name: true,
    location: {
      zip: true
    }
  }]
})

type GetMullhollandUserResult = Infer<typeof getMullhollandUser> // return types without code generation!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.