Huh?
POC for a GraphQL codegen wrapper that requires no configuration and does not generate user-land types or code so nothing needs to be checked in. Like Prisma for React + Apollo.
- Write all of your queries in
sdk.graphql
- Run
generate-some-graphql-sdk <schema-url>
- Use generated code
Demo
See packages/demo
# sdk.graphql
fragment BookDetails on Book {
id
title
author {
id
name
}
}
query GetAuthor($id: ID!) {
author(id: $id) {
id
books {
id
title
}
}
}
query GetBook($id: ID!) {
book(id: $id) {
...BookDetails
}
}
mutation AddBook($book: BookInput!) {
addBook(book: $book) {
...BookDetails
}
}
// src/App.tsx
// this is the NPM package that runs `generate-some-graphql-sdk`
import { sdk } from "some-graphql-cli";
const App = () => {
// full typed client.
const { data } = sdk.useGetBookQuery({ variables: { id: "1" } });
// whatever...
};