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

[FEAT] improve and proper export of ValueTypes #361

Open
Hulkmaster opened this issue Jan 19, 2023 · 0 comments
Open

[FEAT] improve and proper export of ValueTypes #361

Hulkmaster opened this issue Jan 19, 2023 · 0 comments

Comments

@Hulkmaster
Copy link

Hulkmaster commented Jan 19, 2023

one of my colleagues found ValueTypes and its super useful

for example if i have params for mutation i can just use ValueTypes['myMutationParams']

but that was found inside the lib
and it lacks some basic types

I would like to see it as part of official docs and officially supported feature, because it allows me to make consistent TS for api without need for manual rewriting

Our example:

Before

export interface ICreateCampaignPayload {
  input: {
    forwardUrl: string,
    name: string,
    timeframe: {
      startsAt: string,
      endsAt?: string,
    },
    manualInactive?: boolean,
  },
  tenantId: string,
}

After

export interface ICreateCampaignPayload {
  input: ValueTypes['CreateCampaignInput'],
  tenantId: string,
}

Perfectly (but not possible with current implementation)

export interface ICreateCampaignPayload extends ValueTypes['CreateCampaignPayload'] {}

(here i meant that it would be used directly, but for better comparison readability used extend)

Usage

export function apiCreateCampaign(payload: ICreateCampaignPayload) {
  return graphqlClient('mutation', {
    scalars,
  })({
    createCampaign: [
      {
        ...payload,
      },
      {
        ...campaignQuery.campaign,
      },
    ],
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant