Improvement idea: Type safe `composeClient.executeQuery` calls

Similar to what GraphQL request did, it would be amazing to be able to make fully typed calls with
the ComposeDB client. This can be achieved by leveraging graphql code generator.
Graphql-request implementation: GitHub - prisma-labs/graphql-request: Minimal GraphQL client supporting Node and browsers for scripts or simple apps

Ideally, the following would work.

import { graphql } from './gql/gql'

const getMovieQueryDocument = graphql(/* GraphQL */ `
  query getMovie($title: String!) {
    Movie(title: $title) {
      releaseDate
      actors {
        name
      }
    }
  }
`)

const data = await composeClient.executeQuery(
  getMovieQueryDocument,
  // variables are type-checked!
  { title: 'Inception' }
)

// `data.Movie` is typed!
1 Like

FYI @paul @avi, feature request

Leo, great suggestion - captured this in our feedback tracker! I see Prisma already has it implemented. Will figure out how we can prioritize in the backlog.

1 Like