docs: production build optimization#4486
Conversation
yaacovCR
left a comment
There was a problem hiding this comment.
-
A general question/comment: this PR and the related PRs should hopefully take over for the current "going to production" section, right?
-
in terms of this one specifically, I think we need to distinguish between what
graphql-jsitself does in dev vs production mode and the capabilities thatgraphql-jsprovides to libraries/services/tooling/clients usinggraphql-js, some of which might be useful only indevelopment.
In particular, the only thing that graphql-js currently does internally in development mode both in v16/v17 (and I believe v15 and perhaps earlier?) is enable some extra checks within every internal instanceOf() call that powers all graphql-js predicates and causes a minor increase in bundle size and a performance hit.
A good example of the second category of capabilities that graphql-js provides is the 'assumeValidoption that when used will cause the automatic call tovalidateSchemawithinvalidate()andexecute()to short-circuit, i.e. returning without errors. And something similar withinassumeValidSDLwithinbuildSchema/buildASTSchema/extendSchema`.
That's in terms of options, but in terms of functions, any client code that directly calls validateSchema() on a trusted schema or even validate() on a trusted document can be skipped in production.
Note that in v17, we are changing the internal instanceOf to no longer be directed by the NODE_ENV, but rather by the production vs development condition (building on our new support of conditional exports) and with production behavior now enabled b default. See: #4551
00baec0 to
dff99e9
Compare
Replace inaccurate claims and fabricated internals (a non-existent NODE_ENV code block and GRAPHQL_* env vars) with what GraphQL.js actually does: the instanceOf multi-realm check is the only NODE_ENV -gated behavior. Add the assumeValid/assumeValidSDL opt-ins for trusted schemas and operations, note the v17 conditional-exports change (graphql#4551), and cross-link the Development Mode and Going to Production guides. Addresses review feedback from @yaacovCR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
thanks for the helpful feedback!! I went back through the source and reworked the guide :) take a look and let me know what you think |
|
@sarahxsanders is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
First guide in the new GraphQL production guide series, focusing specifically on build optimization for production deployments. Content covers:
I'd love feedback and a review, but please do not merge until the entire production guide series is ready to ship. The focused guides will replace the production monolith that exists today