File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ JSCodeshift transform that inserts Flow types generated from GraphQL documents i
3131 - [ ` external as ` ] ( #external-as- )
3232 - [ ` extract [as ] ` ] ( #extract-as- )
3333- [ CLI Usage] ( #cli-usage )
34+ - [ Node.js API] ( #nodejs-api )
3435
3536<!-- tocstop -->
3637
@@ -726,3 +727,18 @@ type User = {
726727` ` `
727728jscodeshift - t path/ to/ graphql- typegen/ graphql- typegen .js src/* */ * .js
728729` ` `
730+
731+ # Node.js API
732+
733+ Because ` jscodeshift` unfortunately requires transform functions to be sync,
734+ ` graphql- typegen` uses an ` execFileSync` hack to synchronously fetch your schema
735+ from your schema file or server.
736+
737+ If you're calling directly from node, you can bypass this by using ` graphql- typegen- async ` :
738+
739+ ` ` ` js
740+ import graphqlTypegen from ' graphql-typegen/graphql-typegen-async'
741+ ` ` `
742+
743+ It has the same API as a ` jscodeshift` transform, except that it returns a ` Promise ` instead
744+ of a sync result. Maybe someday ` jscodeshift` will support async transforms.
You can’t perform that action at this time.
0 commit comments