-
Notifications
You must be signed in to change notification settings - Fork 324
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(sdl): codemod it all #6228
Conversation
reject(e) | ||
}) | ||
}) | ||
return {newFeature} |
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.
already paying off! the old resolve function wasn't returning anything and the new type caught the error 馃帀
return collector | ||
} | ||
|
||
const resolverMap: Resolvers = { |
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.
we'll never have to touch this file again, everything is automatically imported 馃帀
path.join(__PROJECT_ROOT__, 'packages/server/graphql/private/typeDefs/*.graphql') | ||
) | ||
|
||
const schema = makeExecutableSchema({typeDefs, resolvers}) |
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.
we'll never have to touch this file again, everything is automatically imported 馃帀
@@ -0,0 +1,15 @@ | |||
import {DraftEnterpriseInvoicePayloadResolvers} from '../resolverTypes' | |||
|
|||
export type DraftEnterpriseInvoicePayloadSource = |
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 type has to be manually added & then we have to add it into codegen.json, which isn't great, but it already caught some more type errors
@@ -0,0 +1,166 @@ | |||
/* | |||
Usage: jscodeshift --extensions=tsx,ts,js --parser=tsx -t ./scripts/codeshift/extractResolver.ts ./packages/server/graphql/intranetSchema/queries |
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 walk through this in the loom video.
it's kinda fun if you like metaprogramming
@Dschoordsch I experimented with a default mapper being void or never in order to force devs to explicitly write a The current behavior has a default type == the GraphQL type. This works great for the following cases:
Now the cool part is when the Source type is a subset of the GraphQL type, typescript still throws an error. A good example is user.ts:
This error forces the developer to add an entry to the |
@JimmyLv thought this would be a fun PR for you to review! it's mainly a refactor to make our feature building a little more modern |
@@ -0,0 +1,87 @@ | |||
import {InvoiceItemType, SubscriptionChannel} from 'parabol-client/types/constEnums' | |||
import adjustUserCount from '../../../billing/helpers/adjustUserCount' |
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.
Should we consider using a typescript path to make these ../../../
imports simpler to read?
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.
yes, absolutely. in some places we use ~
to mean parabol-client, and in other places we use symlinks via lerna to get to different packages (e.g. parabol-server, parabol-client
) but getting vscode, webpack, and typescript to all suggest the same pattern has been a bear. We need to take a fresh look at our configs because there's a devil in one of them...
@@ -1,4 +1,5 @@ | |||
module.exports = { | |||
// "*.{ts,tsx}": 'organize-imports-cli', |
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.
Btw, there's a prettier
plugin that does this for you if you want to enable it again someday: https://github.com/simonhaenisch/prettier-plugin-organize-imports#readme
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.
ahhh i've gotta try that next time! this one was buggy & slow
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 didn't review each individual resolver, but this is a great step to further leveraging the modern GraphQL ecosystem!
@JimmyLv hows the review going? any questions or comments? |
This reverts commit a71b95a. The commit breaks the internal resolver.
@mattkrick Hey Matt! This is really excellent! I watched the video earlier, to understand the intent behind this. This is also the first time, I learned how to write a jscodeshift script, understand the magic behind it! |
yep, next step is the public schema! |
Makes sense! I believe the |
This moves graphql/intranetSchema to graphql/private.
It refactors all the objects to SDL-driven development.
It's big, but half of the changes are deletions. The other half are generated, no need to read through the resolve functions, they haven't changed a bit (except for the type errors that this caught 馃帀 )
You can learn more here: https://www.loom.com/share/10ffe21d92014cb6b82f7d8aeb435516
TEST