Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Enhance Type Definitions for GQLExtensions and FetchResponseBody #1813

Open
marcos-mo-loox opened this issue Dec 1, 2024 · 1 comment · May be fixed by #1927
Open

Suggestion: Enhance Type Definitions for GQLExtensions and FetchResponseBody #1813

marcos-mo-loox opened this issue Dec 1, 2024 · 1 comment · May be fixed by #1927
Labels
good first issue Good for newcomers

Comments

@marcos-mo-loox
Copy link

Suggestion: Enhance Type Definitions for GQLExtensions and FetchResponseBody

Background

We are currently working on enhancing our GraphQL infrastructure and are evaluating the integration of this package. During our review, we encountered a few areas where the type definitions could better align with common usage patterns and improve type safety.

Problem Description

  1. GQLExtensions Type

    • Currently, GQLExtensions is typed as Record<string, any>.
    • While this provides flexibility, it lacks specificity and omits fields like cost, which we believe should be included by default.
    • Explicitly including common extension fields like cost would improve the developer experience and reduce ambiguity.
  2. FetchResponseBody Extensions Field

    • The extensions,data,errors,headers fields in FetchResponseBody are optional.
    • However, in our testing, this field is always present in successful responses.
    • Making it required would improve type safety and prevent unnecessary null checks.

Proposed Solution

  • Enhance the GQLExtensions Type

    • Include common fields like cost while maintaining flexibility to accommodate additional fields.
  • Update the FetchResponseBody Type

  • Introduce a SuccessClientResponse type for responses containing data and extensions.

  • Introduce an ErrorClientResponse type for responses containing errors.

This separation would allow for more explicit handling of success and error scenarios, aligning with common GraphQL response patterns.

Question

Would these changes align with your roadmap for the package? We believe this improvement could enhance the package’s usability for GraphQL clients.

Thank you for your consideration!

@lizkenyon
Copy link
Contributor

Hi there 👋

Thank you for the flag! To clarify you are speaking about the GraphQL client package specifically?
If you would like to make a PR the team would prioritize reviewing it.
Otherwise I can add this to the teams backlog.

@lizkenyon lizkenyon added the good first issue Good for newcomers label Dec 6, 2024
@admirsaheta admirsaheta linked a pull request Jan 7, 2025 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants