Skip to content

Conversation

@Fran-A-Dev
Copy link
Contributor

@Fran-A-Dev Fran-A-Dev commented Dec 19, 2024

Wait to merge and review this one as well.


dependabot bot and others added 10 commits July 30, 2024 09:27
Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) from 4.2.5 to 4.4.1.
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](NaturalIntelligence/fast-xml-parser@v4.2.5...v4.4.1)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [dset](https://github.com/lukeed/dset) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/lukeed/dset/releases)
- [Commits](lukeed/dset@v3.1.3...v3.1.4)

---
updated-dependencies:
- dependency-name: dset
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8.
- [Release notes](https://github.com/micromatch/micromatch/releases)
- [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md)
- [Commits](micromatch/micromatch@4.0.5...4.0.8)

---
updated-dependencies:
- dependency-name: micromatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [path-to-regexp](https://github.com/pillarjs/path-to-regexp) from 6.2.1 to 6.3.0.
- [Release notes](https://github.com/pillarjs/path-to-regexp/releases)
- [Changelog](https://github.com/pillarjs/path-to-regexp/blob/master/History.md)
- [Commits](pillarjs/path-to-regexp@v6.2.1...v6.3.0)

---
updated-dependencies:
- dependency-name: path-to-regexp
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [next](https://github.com/vercel/next.js) from 14.1.1 to 14.2.12.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](vercel/next.js@v14.1.1...v14.2.12)

---
updated-dependencies:
- dependency-name: next
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](moxystudio/node-cross-spawn@v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
…pawn-7.0.6

Bump cross-spawn from 7.0.3 to 7.0.6
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@moonmeister
Copy link
Member

@Fran-A-Dev what are we waiting for on this one?

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.


[View the Faust.js TypeScript scaffold application](https://github.com/wpengine/faust-scaffold-ts)

### Using graphql-codegen
Copy link
Member

Choose a reason for hiding this comment

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

Why are we showing graphql codegen here? Don't we have our own generate command for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because it showed in the original docs here and it tells the user to consider it:
https://faustjs.org/guide/how-to-implement-typescript

Should I just do away with codegen @moonmeister ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, my best guess is this doc was written before our built in generate command had shipped and it was never updated. Let's get that fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good will fix it

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@moonmeister moonmeister force-pushed the doc/implement-TypeScript branch from b829c14 to be9dc0b Compare January 2, 2025 19:31
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript https://hr…wered.com ✅ (logs)

Learn more about preview environments in our documentation.

@moonmeister moonmeister marked this pull request as draft January 3, 2025 00:26
@moonmeister
Copy link
Member

okay. So this makes even less sense after the changes. What I asked before was whether Typing GraphQL was accomplished through the cli command faust generatePossibleTypes. You've changed the dsribed CLI command but nothing else here so now none of this would work cause the possible types command doesn't generate most of these files.

More reasearch suggests possible types is specific to Apollo and GraphQL Fragments. Nothing to do with TypeScript.

Let's make sure we undestand and test the docs we're writing.

  1. Let's revert this doc have the correct codegen steps. These steps should probably to be modified to account for the fact that we have default configs for the generate script for possible types.
  2. The "Step" prefix should be removed from the steps...most our docs are just 1...2...3...etc and that's plenty.
  3. Let's give this how-to a more specific and apropriate title e.g. "Typing the GraphQL Client", "Generating Types for Apollo Client",

@Fran-A-Dev
Copy link
Contributor Author

Fran-A-Dev commented Jan 3, 2025

okay. So this makes even less sense after the changes. What I asked before was whether Typing GraphQL was accomplished through the cli command faust generatePossibleTypes. You've changed the dsribed CLI command but nothing else here so now none of this would work cause the possible types command doesn't generate most of these files.

More reasearch suggests possible types is specific to Apollo and GraphQL Fragments. Nothing to do with TypeScript.

Let's make sure we undestand and test the docs we're writing.

  1. Let's revert this doc have the correct codegen steps. These steps should probably to be modified to account for the fact that we have default configs for the generate script for possible types.
  2. The "Step" prefix should be removed from the steps...most our docs are just 1...2...3...etc and that's plenty.
  3. Let's give this how-to a more specific and apropriate title e.g. "Typing the GraphQL Client", "Generating Types for Apollo Client",

Oh, gotcha. @moonmeister I did test the generate command and it worked fine. What I misunderstood was I thought you said GraphQL code gen step was not necessary at all and it would automate that within Faust. When I ran the command, it said the types in the terminal were updated. That is why I thought it was all good to go. Also, I do not use TS much. I'll add your suggestions and test again but I'll need your help to make sure it is what we want. Let's hop on a call next week or we can just use the dev time we have allocated on Wednesdays to check the docs on this. Thanks my dev dude!

@moonmeister
Copy link
Member

@Fran-A-Dev sounds good. I don't either at least not with Faust, so hopefully we can get this sorted together.

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript N/A ❌ (logs)

Learn more about preview environments in our documentation.

@Fran-A-Dev
Copy link
Contributor Author

@Fran-A-Dev sounds good. I don't either at least not with Faust, so hopefully we can get this sorted together.

@moonmeister I rewrote the doc to make more sense per your suggestions which made more sense than the current doc page I took this from. Here are the summary of changes I made:

  • Removed references to faust generatePossibleTypes for typing.
  • Restored the correct instructions for using @graphql-codegen/cli to generate TypeScript definitions.
  • Renamed the doc to a more specific title: “Typing The GraphQL Client.”
  • Removed “Step X” language in favor of numbered headings or plain headings.
  • Verified each snippet and command so that everything matches up with the actual Faust/GraphQL Codegen workflow.

Try the steps, I just went through them and it works.

@Fran-A-Dev Fran-A-Dev marked this pull request as ready for review January 8, 2025 16:34
@kellenmace
Copy link
Collaborator

@Fran-A-Dev I spent some time looking into this today and made a few tweaks to the wording in both the basic setup doc at the implementing TS doc.

The steps for implementing TS don't actually work. That's because when Faust's npm run generate command is run, possibleTypes.json and globalStylesheet.css files are created, but no .ts files are created, which is what a developer actually needs if they want to be able to import and use types.

The possibleTypes.json file is a JSON file is passed into Apollo Client so it can "understand the polymorphic relationship between X interface and the types that implement it" (docs are here). This helps when working with GraphQL fragments.

And the globalStylesheet.css file contains global styles from the WP backend that can be imported and used in the decoupled frontend.

Since running npm run generate does not generate a .ts file containing types that devs can make use of, more work is required.

Since Faust is already using GraphQL Codegen to run an introspection query against the /graphql endpoint's schema and generate the possibleTypes.json file, it would be nice to us to be able to tweak it so that it also produces a .ts file containing the types, like by passing a flag such as "generate": "faust generatePossibleTypes --use-ts or something. Unfortunately, that's not how Faust works currently. So I think we'll need to go back to showing devs how to set up and run GraphQL Codegen themselves to generates the types, just like the current https://faustjs.org/guide/how-to-implement-typescript page does. One change I think we should make, though:
Since the "generate": "faust generatePossibleTypes" script already exists in the package.json file of Faust projects, telling devs to add a "generate": "graphql-codegen", command to their package.json file like the current does site does doesn't make any sense. I think we should instead tell devs to update that script to be "generate": "faust generatePossibleTypes && graphql-codegen", so that both commands are run. The former will still generate the possibleTypes.json and globalStylesheet.css files, and the latter will generate the .ts files they can use in their project.

Happy to work on this with you when we come back on Monday. Thanks for working on it, Fran!

cc: @moonmeister

@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript N/A ❌ (logs)

Learn more about preview environments in our documentation.

@Fran-A-Dev
Copy link
Contributor Author

@Fran-A-Dev I spent some time looking into this today and made a few tweaks to the wording in both the basic setup doc at the implementing TS doc.

The steps for implementing TS don't actually work. That's because when Faust's npm run generate command is run, possibleTypes.json and globalStylesheet.css files are created, but no .ts files are created, which is what a developer actually needs if they want to be able to import and use types.

The possibleTypes.json file is a JSON file is passed into Apollo Client so it can "understand the polymorphic relationship between X interface and the types that implement it" (docs are here). This helps when working with GraphQL fragments.

And the globalStylesheet.css file contains global styles from the WP backend that can be imported and used in the decoupled frontend.

Since running npm run generate does not generate a .ts file containing types that devs can make use of, more work is required.

Since Faust is already using GraphQL Codegen to run an introspection query against the /graphql endpoint's schema and generate the possibleTypes.json file, it would be nice to us to be able to tweak it so that it also produces a .ts file containing the types, like by passing a flag such as "generate": "faust generatePossibleTypes --use-ts or something. Unfortunately, that's not how Faust works currently. So I think we'll need to go back to showing devs how to set up and run GraphQL Codegen themselves to generates the types, just like the current https://faustjs.org/guide/how-to-implement-typescript page does. One change I think we should make, though: Since the "generate": "faust generatePossibleTypes" script already exists in the package.json file of Faust projects, telling devs to add a "generate": "graphql-codegen", command to their package.json file like the current does site does doesn't make any sense. I think we should instead tell devs to update that script to be "generate": "faust generatePossibleTypes && graphql-codegen", so that both commands are run. The former will still generate the possibleTypes.json and globalStylesheet.css files, and the latter will generate the .ts files they can use in their project.

Happy to work on this with you when we come back on Monday. Thanks for working on it, Fran!

cc: @moonmeister

Thanks for taking a look and testing this out @kellenmace ! Yes, let's take a look at this together and decide on the clear fix for the doc.

…d 'implmenenting-typescript' doc, minor wording and code syntax highlighting updates
@headless-platform-by-wp-engine

Check out the recent updates to your Headless Platform preview environment:

App Environment URL Build
faustjs.org preview-env-doc/implement-TypeScript N/A ❌ (logs)

Learn more about preview environments in our documentation.

@kellenmace kellenmace merged commit 1d5b308 into toolkit Jan 13, 2025
3 of 4 checks passed
@kellenmace kellenmace deleted the doc/implement-TypeScript branch January 13, 2025 20:17
@moonmeister moonmeister restored the doc/implement-TypeScript branch January 15, 2025 00:14
This was referenced Jan 15, 2025
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.

5 participants