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(core): Leverage gql.tada for typings #119

Merged
merged 15 commits into from
Jan 17, 2024
Merged

feat(core): Leverage gql.tada for typings #119

merged 15 commits into from
Jan 17, 2024

Conversation

JoviDeCroock
Copy link
Contributor

@JoviDeCroock JoviDeCroock commented Jan 16, 2024

The issue I am having here conceptually is that folks need graphqlsp to work correctly so that the introspection.ts file gets outputted correctly. Currently thinking whether we can establish a few safeguards here.

The goal here is for new users to gain access to gql.tada while former users don't have to change up their code and can stick to the LSP.

I have updated the documentation with both a migrating to and disabling chunk.

Resolves #70

Copy link

vercel bot commented Jan 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fusejs-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 2:01pm
spacex-fuse ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 17, 2024 2:01pm

@@ -91,6 +91,7 @@ prog
}

if (opts.client) {
// TODO: bail out when the user is using gql.tada
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking here is basically that we can check whether

  1. We have a valid gql.tada installation
  2. We have the config set in the tsconfig

If the above don't hold up we need to codegen to support users with prior generated code

Copy link
Member

Choose a reason for hiding this comment

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

This is beautiful for this migration for any early users we have. I'd love to be able to remove codegen entirely in v1.0!

Copy link
Member

@mxstbr mxstbr left a comment

Choose a reason for hiding this comment

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

This is AWESOME!!! :shipit:

}) => {
const result = useFragment(SiteLocationFields, props.location)
const result = readFragment(SiteLocationFields, props.location)
Copy link
Member

Choose a reason for hiding this comment

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

:chef-kiss:

@@ -10,9 +10,9 @@ const SiteLocationFields = graphql(`
`)

export const Location = (props: {
location: FragmentType<typeof SiteLocationFields>
location: FragmentOf<typeof SiteLocationFields>
Copy link
Member

Choose a reason for hiding this comment

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

:chef-kiss:

path.resolve(base, 'fuse/index.ts'),
`// This is a generated file!\n\nexport * from './tada';\nexport * from 'fuse/client';\n`,
),
fs.writeFile(path.resolve(base, 'fuse/tada.ts'), tadaGqlContents),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the future when folks use custom scalars, ... we might not want to override this

}>()

export type { FragmentOf, ResultOf, VariablesOf } from 'gql.tada'
export type { FragmentOf as FragmentType } from 'gql.tada'
Copy link
Contributor Author

@JoviDeCroock JoviDeCroock Jan 17, 2024

Choose a reason for hiding this comment

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

Added some aliases for backwards compat and docs clarity

@mxstbr
Copy link
Member

mxstbr commented Jan 17, 2024

CleanShot 2024-01-17 at 05 55 43@2x

SO GOOD

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.

Don't empty the generated files during generation
2 participants