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

Updates for GraphQL schema ordering and TypeScript type generation #9258

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

dcousens
Copy link
Member

@dcousens dcousens commented Aug 5, 2024

This pull request changes some of the ordering in our GraphQL types, and begins to introduces a differentiation between GraphQL types and resolved (or Prisma) types in our generated Typescript types.

This change is important as it begins to address a state where these types do not always match. The reason for that will be evident in #2480, but additionally, it refactors the Typescript type generation to start accounting for separate Typescript types for a sudo() context.

Primarily for now though, this pull request inlines parts of the printGeneratedTypes and orders the outputs more consistently.

@dcousens dcousens changed the title Diff graphql prisma types Updates for Typescript type generation Aug 5, 2024
@dcousens dcousens changed the title Updates for Typescript type generation Updates for GraphQL schema ordering and TypeScript type generation Aug 5, 2024
user(where: UserWhereUniqueInput!): User
users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be a noisy update for developers, but, this has been an inconsistency in our code for many moons, and is annoying to uphold.

Copy link

codesandbox-ci bot commented Aug 5, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9594b52:

Sandbox Source
@keystone-6/sandbox Configuration


const name = type.name
if (type instanceof GraphQLScalarType) {
if (scalars[name] === undefined) return 'any'
return `Scalars['${stringify(name)}']` // TODO: inline?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we needed to refer to this Scalars object continually for our resolved types; this isn't helpful to developers.

@@ -84,7 +74,7 @@ export type TodoUpdateArgs = {
}

export type TodoCreateInput = {
readonly title?: Scalars['String'] | null
readonly title?: string | null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is easier on the eyes from a developer documentation point of view

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been annoyed by this scalar in generating types to be used with separate frontend app.

@dcousens dcousens force-pushed the diff-graphql-prisma-types branch 2 times, most recently from 6c65ac8 to 097c846 Compare August 5, 2024 06:50
@dcousens dcousens merged commit 1a9ff0a into main Aug 5, 2024
42 of 43 checks passed
@dcousens dcousens deleted the diff-graphql-prisma-types branch August 5, 2024 07:18
@dcousens dcousens mentioned this pull request Aug 9, 2024
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

Successfully merging this pull request may close these issues.

2 participants