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

Refine generated schema types #1773

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/gnt/app/1588-infinite-fetch/gqty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const cache = new Cache(
* allowing soft refetches in background.
*/
{
maxAge: 0,
staleWhileRevalidate: 5 * 60 * 1000,
maxAge: 5000,
staleWhileRevalidate: 30 * 60 * 1000,
normalization: true,
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/gnt/app/components/CscCharactersSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useState, type FunctionComponent } from 'react';
import Button from '~/components/tailwindui/Button';
import type { Character, Characters, Maybe } from '~/gqty';
import type { Character, Maybe } from '~/gqty';
import { useQuery } from '~/gqty/react';
import Avatar from './Avatar';
import Card from './Card';
Expand Down
4 changes: 2 additions & 2 deletions examples/gnt/gqty/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const cache = new Cache(
* allowing soft refetches in background.
*/
{
maxAge: 0,
staleWhileRevalidate: 5 * 60 * 1000,
maxAge: 5000,
staleWhileRevalidate: 30 * 60 * 1000,
normalization: true,
}
);
Expand Down
125 changes: 71 additions & 54 deletions examples/gnt/gqty/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* GQty AUTO-GENERATED CODE: PLEASE DO NOT MODIFY MANUALLY
*/

import { type ScalarsEnumsHash } from 'gqty';

export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = {
Expand All @@ -13,15 +15,24 @@ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
[SubKey in K]: Maybe<T[SubKey]>;
};
export type MakeEmpty<
T extends { [key: string]: unknown },
K extends keyof T
> = { [_ in K]?: never };
export type Incremental<T> =
| T
| {
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
};
/** All built-in and custom scalars, mapped to their actual values */
export interface Scalars {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
ID: { input: string; output: string };
String: { input: string; output: string };
Boolean: { input: boolean; output: boolean };
Int: { input: number; output: number };
Float: { input: number; output: number };
/** The `Upload` scalar type represents a file upload. */
Upload: any;
Upload: { input: any; output: any };
}

export enum CacheControlScope {
Expand All @@ -30,25 +41,25 @@ export enum CacheControlScope {
}

export interface FilterCharacter {
gender?: InputMaybe<Scalars['String']>;
name?: InputMaybe<Scalars['String']>;
species?: InputMaybe<Scalars['String']>;
status?: InputMaybe<Scalars['String']>;
type?: InputMaybe<Scalars['String']>;
gender?: InputMaybe<Scalars['String']['input']>;
name?: InputMaybe<Scalars['String']['input']>;
species?: InputMaybe<Scalars['String']['input']>;
status?: InputMaybe<Scalars['String']['input']>;
type?: InputMaybe<Scalars['String']['input']>;
}

export interface FilterEpisode {
episode?: InputMaybe<Scalars['String']>;
name?: InputMaybe<Scalars['String']>;
episode?: InputMaybe<Scalars['String']['input']>;
name?: InputMaybe<Scalars['String']['input']>;
}

export interface FilterLocation {
dimension?: InputMaybe<Scalars['String']>;
name?: InputMaybe<Scalars['String']>;
type?: InputMaybe<Scalars['String']>;
dimension?: InputMaybe<Scalars['String']['input']>;
name?: InputMaybe<Scalars['String']['input']>;
type?: InputMaybe<Scalars['String']['input']>;
}

export const scalarsEnumsHash: import('gqty').ScalarsEnumsHash = {
export const scalarsEnumsHash: ScalarsEnumsHash = {
Boolean: true,
CacheControlScope: true,
ID: true,
Expand Down Expand Up @@ -154,48 +165,48 @@ export interface Character {
/**
* Time at which the character was created in the database.
*/
created?: Maybe<ScalarsEnums['String']>;
created?: Maybe<Scalars['String']['output']>;
/**
* Episodes in which this character appeared.
*/
episode: Array<Maybe<Episode>>;
/**
* The gender of the character ('Female', 'Male', 'Genderless' or 'unknown').
*/
gender?: Maybe<ScalarsEnums['String']>;
gender?: Maybe<Scalars['String']['output']>;
/**
* The id of the character.
*/
id?: Maybe<ScalarsEnums['ID']>;
id?: Maybe<Scalars['ID']['output']>;
/**
* Link to the character's image.
* All images are 300x300px and most are medium shots or portraits since they are intended to be used as avatars.
*/
image?: Maybe<ScalarsEnums['String']>;
image?: Maybe<Scalars['String']['output']>;
/**
* The character's last known location
*/
location?: Maybe<Location>;
/**
* The name of the character.
*/
name?: Maybe<ScalarsEnums['String']>;
name?: Maybe<Scalars['String']['output']>;
/**
* The character's origin location
*/
origin?: Maybe<Location>;
/**
* The species of the character.
*/
species?: Maybe<ScalarsEnums['String']>;
species?: Maybe<Scalars['String']['output']>;
/**
* The status of the character ('Alive', 'Dead' or 'unknown').
*/
status?: Maybe<ScalarsEnums['String']>;
status?: Maybe<Scalars['String']['output']>;
/**
* The type or subspecies of the character.
*/
type?: Maybe<ScalarsEnums['String']>;
type?: Maybe<Scalars['String']['output']>;
}

export interface Characters {
Expand All @@ -209,27 +220,27 @@ export interface Episode {
/**
* The air date of the episode.
*/
air_date?: Maybe<ScalarsEnums['String']>;
air_date?: Maybe<Scalars['String']['output']>;
/**
* List of characters who have been seen in the episode.
*/
characters: Array<Maybe<Character>>;
/**
* Time at which the episode was created in the database.
*/
created?: Maybe<ScalarsEnums['String']>;
created?: Maybe<Scalars['String']['output']>;
/**
* The code of the episode.
*/
episode?: Maybe<ScalarsEnums['String']>;
episode?: Maybe<Scalars['String']['output']>;
/**
* The id of the episode.
*/
id?: Maybe<ScalarsEnums['ID']>;
id?: Maybe<Scalars['ID']['output']>;
/**
* The name of the episode.
*/
name?: Maybe<ScalarsEnums['String']>;
name?: Maybe<Scalars['String']['output']>;
}

export interface Episodes {
Expand All @@ -243,47 +254,47 @@ export interface Info {
/**
* The length of the response.
*/
count?: Maybe<ScalarsEnums['Int']>;
count?: Maybe<Scalars['Int']['output']>;
/**
* Number of the next page (if it exists)
*/
next?: Maybe<ScalarsEnums['Int']>;
next?: Maybe<Scalars['Int']['output']>;
/**
* The amount of pages.
*/
pages?: Maybe<ScalarsEnums['Int']>;
pages?: Maybe<Scalars['Int']['output']>;
/**
* Number of the previous page (if it exists)
*/
prev?: Maybe<ScalarsEnums['Int']>;
prev?: Maybe<Scalars['Int']['output']>;
}

export interface Location {
__typename?: 'Location';
/**
* Time at which the location was created in the database.
*/
created?: Maybe<ScalarsEnums['String']>;
created?: Maybe<Scalars['String']['output']>;
/**
* The dimension in which the location is located.
*/
dimension?: Maybe<ScalarsEnums['String']>;
dimension?: Maybe<Scalars['String']['output']>;
/**
* The id of the location.
*/
id?: Maybe<ScalarsEnums['ID']>;
id?: Maybe<Scalars['ID']['output']>;
/**
* The name of the location.
*/
name?: Maybe<ScalarsEnums['String']>;
name?: Maybe<Scalars['String']['output']>;
/**
* List of characters who have been last seen in the location.
*/
residents: Array<Maybe<Character>>;
/**
* The type of the location.
*/
type?: Maybe<ScalarsEnums['String']>;
type?: Maybe<Scalars['String']['output']>;
}

export interface Locations {
Expand All @@ -301,53 +312,53 @@ export interface Query {
/**
* Get a specific character by ID
*/
character: (args: { id: Scalars['ID'] }) => Maybe<Character>;
character: (args: { id: Scalars['ID']['input'] }) => Maybe<Character>;
/**
* Get the list of all characters
*/
characters: (args?: {
filter?: Maybe<FilterCharacter>;
page?: Maybe<Scalars['Int']>;
page?: Maybe<Scalars['Int']['input']>;
}) => Maybe<Characters>;
/**
* Get a list of characters selected by ids
*/
charactersByIds: (args: {
ids: Array<Scalars['ID']>;
ids: Array<Scalars['ID']['input']>;
}) => Maybe<Array<Maybe<Character>>>;
/**
* Get a specific episode by ID
*/
episode: (args: { id: Scalars['ID'] }) => Maybe<Episode>;
episode: (args: { id: Scalars['ID']['input'] }) => Maybe<Episode>;
/**
* Get the list of all episodes
*/
episodes: (args?: {
filter?: Maybe<FilterEpisode>;
page?: Maybe<Scalars['Int']>;
page?: Maybe<Scalars['Int']['input']>;
}) => Maybe<Episodes>;
/**
* Get a list of episodes selected by ids
*/
episodesByIds: (args: {
ids: Array<Scalars['ID']>;
ids: Array<Scalars['ID']['input']>;
}) => Maybe<Array<Maybe<Episode>>>;
/**
* Get a specific locations by ID
*/
location: (args: { id: Scalars['ID'] }) => Maybe<Location>;
location: (args: { id: Scalars['ID']['input'] }) => Maybe<Location>;
/**
* Get the list of all locations
*/
locations: (args?: {
filter?: Maybe<FilterLocation>;
page?: Maybe<Scalars['Int']>;
page?: Maybe<Scalars['Int']['input']>;
}) => Maybe<Locations>;
/**
* Get a list of locations selected by ids
*/
locationsByIds: (args: {
ids: Array<Scalars['ID']>;
ids: Array<Scalars['ID']['input']>;
}) => Maybe<Array<Maybe<Location>>>;
}

Expand All @@ -361,10 +372,16 @@ export interface GeneratedSchema {
subscription: Subscription;
}

export type MakeNullable<T> = {
[K in keyof T]: T[K] | undefined;
};
type Enums = {};

export interface ScalarsEnums extends MakeNullable<Scalars> {
CacheControlScope: CacheControlScope | undefined;
}
export type InputFields = {
[Key in keyof Scalars]: Scalars[Key] extends { input: unknown }
? Scalars[Key]['input']
: never;
} & Enums;

export type OutputFields = {
[Key in keyof Scalars]: Scalars[Key] extends { output: unknown }
? Scalars[Key]['output']
: never;
} & Enums;
2 changes: 1 addition & 1 deletion examples/gnt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"scripts": {
"codegen": "dotenv -c local -- bash -c 'pnpm exec gqty --no-react -H apiKey:$NEXT_PUBLIC_SUPABASE_API_KEY $NEXT_PUBLIC_SUPABASE_ENDPOINT'",
"codegen": "dotenv -c local -- bash -c 'pnpm exec gqty --no-react https://rickandmortyapi.com/graphql'",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const paginatedData: {
}[] = new Array(200).fill(0).map((_, index) => {
return {
id: index + '',
name: faker.name.firstName(),
name: faker.person.firstName(),
};
});

Expand Down
Loading
Loading