dotansimha / dotansimha/graphql-code-generator-community

🔥 [gql-tag-operations]: Generate gql operations with named operations + query variable types

Open
#216 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

## Background
### I've been using a number of GraphQL-related tools, but I still haven't found one that allows me to not having to manually write out every GraphQL operation `with dynamic query parameters` based on the gql schema

## 🔨🔨 What I'm doing manually
```ts
import { gql } from '@apollo/client';

export const CREATE_PERSONAL_INFO = gql`
mutation CREATE_PERSONAL_INFO($data: PersonalInfoCreateInput!) {
createPersonalInfo(data: $data) {
id
}
}
`;

export const UPDATE_PERSONAL_INFO = gql`
mutation UPDATE_PERSONAL_INFO(
$where: PersonalInfoWhereUniqueInput!
$data: PersonalInfoUpdateInput!
) {
updatePersonalInfo(where: $where, data: $data) {
updatedAt
}
}
`;
```
You see, I have a separate `/src/graphql/Mutations.ts` file dedicated for storing operations to make sure they're reusable, especially when doing `refetchQueries` on record creation and update type of operations. I'd like to eliminate the manual process for writing out standard crud operation queries and see if there are any plans moving forward with this idea.

Manually writing out operations can be risky especially if your schema has lots of nested fields and advanced filters, like mine. This is why I'm looking for ways to automate the process.

GraphQL schema: https://github.com/Mingyang-Li/VisaPro/blob/main/server/schema.graphql

GraphQL frontend operations: https://github.com/Mingyang-Li/VisaPro/blob/main/client-ui/src/graphql/Mutations.ts

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.