-
Notifications
You must be signed in to change notification settings - Fork 1k
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
GraphQL Codegen for generating gql types #2485
Conversation
6f7b13e
to
99ae71d
Compare
99ae71d
to
8037df6
Compare
5d8b034
to
cc0bebe
Compare
All type generation now under rw g types Move watcher one level up, so it can be reused more easily for other actions
…-codegen * 'main' of github.com:redwoodjs/redwood: (54 commits) Add private methods loose explicitly (redwoodjs#2554) Custom `useAuth` pass through for `RedwoodApolloProvider` (redwoodjs#2455) Prerender all routes nested in Set with prerender prop (redwoodjs#2542) Upgrade eslint and prettier packages including formatting fixes (redwoodjs#2540) contributors updates (redwoodjs#2544) Rename default datasource (redwoodjs#1941) Add default config for Component generation (redwoodjs#1814) build(deps): bump core-js from 3.10.1 to 3.12.1 (redwoodjs#2481) upgrade babel 7.14.2 with misc babel packages (redwoodjs#2541) build(deps): bump http-proxy-middleware from 1.1.0 to 2.0.0 (redwoodjs#2536) build(deps): bump pino-pretty from 4.7.1 to 4.8.0 (redwoodjs#2534) build(deps): bump concurrently from 6.0.2 to 6.1.0 (redwoodjs#2533) build(deps-dev): bump firebase-admin from 9.7.0 to 9.8.0 (redwoodjs#2522) build(deps): bump esbuild-loader from 2.10.0 to 2.13.0 (redwoodjs#2518) build(deps): bump @graphql-tools/merge from 6.2.13 to 6.2.14 (redwoodjs#2516) updating minor dependency versions across packages (redwoodjs#2532) Add JSON headers to Function generator template (redwoodjs#2457) fixed firebase promises so that they can be caught (redwoodjs#2503) Prevent re-initialization of a Firebase app that is already initialized (redwoodjs#2504) build(deps-dev): bump magic-sdk from 2.7.0 to 4.3.0 (redwoodjs#2463) ...
export { createCell } | ||
|
||
/** @deprecated `withCell` will be removed in v0.32.0, please use `createCell` instead. */ | ||
export const withCell = createCell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I've removed withCell
…-codegen * 'main' of github.com:redwoodjs/redwood: Adds option to cell generation for lists of a given model (redwoodjs#2569) Router: More helpful typings for Route (redwoodjs#2592) upgrade Prisma v2.23.0 (redwoodjs#2566) add crowdin contribs (redwoodjs#2560) `rw exec` to run arbitary scripts in Redwood context (redwoodjs#2548)
@@ -169,7 +169,7 @@ export const Success = ({ userProfile }) => { | |||
|
|||
exports[`creates a cell mock with a camelCase word name 1`] = ` | |||
"// Define your own mock data here: | |||
export const standard = (/* vars, { ctx, req } */) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dunno why the snapshots do this weird thing. Its not actually doing this when we actually generate 🤷♂️
@@ -414,7 +416,7 @@ describe('UserProfileCell', () => { | |||
`; | |||
|
|||
exports[`creates a cell test with a multi word name 1`] = ` | |||
"import { render, screen } from '@redwoodjs/testing' | |||
"import { render } from '@redwoodjs/testing' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another one of the weird snapshot things. Something to do with tsToJs maybe
@@ -101,10 +100,16 @@ export const handler = async ({ | |||
command: `cd "${path.join( | |||
BASE_DIR, | |||
'web' | |||
)}" && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js ${forward}`, | |||
)}" && yarn cross-env NODE_ENV=development webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js ${forward}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also allow us to use tailwind's JIT without more hassle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small things that are problems, but overall looks good to me!
@@ -1,39 +1,43 @@ | |||
import { useQuery, OperationResult } from './GraphQLHooksProvider' | |||
import { A } from 'ts-toolbelt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a devDependency
import { A } from 'ts-toolbelt' | |
import { A } from 'ts-toolbelt' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha not sure what the change here is peter! But yes its a devDep, did you mean import type only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, I don't know why I used the suggestion tool... top-kek!
I mean that because it's a devDependency it won't be installed for users, and it looks like a "design time requirement," basically I'm not sure what the type looks like when it's generated? Does it reference A
or does it interpolate that value and expand it in the generated type def?
Let's combine the efforts for creating docs once I've merged my two TS generation PRs. |
…-codegen * 'main' of github.com:redwoodjs/redwood: Removes console warnings in webhook verifiers (redwoodjs#2563) build(deps): bump eslint from 7.26.0 to 7.27.0 (redwoodjs#2610) CONTRIBUTING.md: styling tweaks for improved readability and consistency (redwoodjs#2608) build(deps): bump esbuild from 0.11.21 to 0.12.1 (redwoodjs#2579) Cache magic.link's token (redwoodjs#2555) build(deps): bump @babel/plugin-transform-runtime from 7.14.2 to 7.14.3 (redwoodjs#2603) build(deps): bump @types/node from 15.3.1 to 15.6.0 (redwoodjs#2601) eslint-plugin-import 2.23.2 with lint fixes (redwoodjs#2604) build(deps): bump @apollo/client from 3.3.18 to 3.3.19 (redwoodjs#2576) build(deps): bump apollo-server-lambda from 2.22.2 to 2.24.1 (redwoodjs#2580) build(deps): bump babel-plugin-graphql-tag from 3.2.0 to 3.3.0 (redwoodjs#2600) build(deps): bump @babel/cli from 7.13.16 to 7.14.3 (redwoodjs#2578) build(deps-dev): bump @types/lodash from 4.14.169 to 4.14.170 (redwoodjs#2597) build(deps-dev): bump @types/findup-sync from 2.0.2 to 4.0.0 (redwoodjs#2574) Aggregate Dependabot misc patch minor upgrades (redwoodjs#2596) CONTRIBUTING.md: add missing char (redwoodjs#2594) changes test command instructions to reference run-e2e instead of test-tutorial (redwoodjs#2593)
What does it do?
yarn rw generate types
which will generate all autogenerated types (currently CurrentUser and graphql types)yarn rw dev
to also call above generatorQueryOperationResult
andMutationOperationResult
overridable types so that when you bring your gql client, you can add your own types. (See packages/web/src/apollo/typeOverride.ts)The generated types can be used like this:
You also get types from the Apollo client! (Overridable for other clients)
I realise that its unusal that
rw generate types --watch
has a watch flag, open to suggestions for a better way. I just thought generate was the best place to put this.Uses graphql-codegen underneath.
Outstanding tasks:
Investigate usingmakeMergeSchema
instead of the actual api server for generating typesUpdate: Peter's cell mirrored types may generate the schema to a file, which we can reuse.
was already done in another PR
...queryRest
).stories.tsx
,.tests.tsx
and.mocks.ts
Closes #418