Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Convenience Client class generation #21

Closed
timkendall opened this issue Dec 25, 2020 · 0 comments · Fixed by #22
Closed

Convenience Client class generation #21

timkendall opened this issue Dec 25, 2020 · 0 comments · Fixed by #22
Labels
enhancement New feature or request

Comments

@timkendall
Copy link
Owner

In-order-to help with ease of use, we could generate a thin Client class wrapper around our query, mutation, and subscription primitives. It would expose methods for each top-level operation (as well-as expose more flexible query and mutation methods).

Example (with Starwars schema):

import { Transport, Operation } from '@timkendall/tql'

export class Starwars {
  constructor(private readonly transport: Transport) {}
  
  public viewer(select: ViewerSelector) {}

  public addReview(variables: AddReviewInput, select: AddReviewSelector ) {}

  public query(name: string, select: QuerySelector) {}

  public mutate(name: string, select: MutationSelector) {}

  private execute<T>(operation: Operation<T>) {
    //  execute GraphQL operation against `this.transport`
  }
}
@timkendall timkendall added the enhancement New feature or request label Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant