
add-resolver
npm run add:resolver -- --args <workspacePath> <resolverName> <resolverDescription> <resolverType> ...
npx turbo gen resolver --args <workspacePath> <resolverName> <resolverDescription> <resolverType> ...
- add-resolver.ts
Prompt Arguments
Argument | Type | Question / Description |
---|---|---|
workspacePath | autocomplete | Where would you like to add this resolver? => e.g. features/@app-core |
resolverName | text | What is the resolver name? => string |
resolverDescription | text | Optional description: What will this data resolver do? => string |
resolverType | radio | Will this resolver query or mutate data? => query / mutation |
generatables | checklist | What would you like to generate linked to this resolver? => GRAPHQL / GET / POST / PUT / DELETE / formHook |
inputSchemaTarget | autocomplete | Which schema should we use for the resolver inputs? => e.g. HealthCheckInput |
inputSchemaName | text | What will you call this new input schema? => string |
outputSchemaTarget | autocomplete | Which schema should we use for the resolver output? => e.g. HealthCheckOutput |
outputSchemaName | text | What will you call this new output schema? => string |
apiPath | text | What API path would you like to use for REST? => e.g. /api/some/endpoint/with/[params]/ |
formHookName | text | What should the form hook be called? => e.g. useSomeResolver |
Resulting File Changes
/apps/next/
└── app/(generated)/{routePath}/route.ts ❇️ # <- e.g. '/api/some/endpoint/with/[params]/' (Next.js route handler)
/{workspacePath}/ # <- e.g. 'features/@app-core/' or 'packages/some-package/'
└── resolvers/
└── {resolverName}.bridge.ts ❇️ # <- Bridge Metadata file for the resolver and API
└── {resolverName}.resolver.ts ❇️ # <- Reusable Fn with Business logic (server only)
└── {resolverName}.{resolverType}.ts ❇️ # <- e.g. `query` / `mutation` fetcher
└── routes/
└── {apiPath}/ ❇️ # <- e.g. '/api/some/endpoint/with/[params]/'
└── route.ts ❇️ # <- If `GET` / `POST` / `PUT` / `DELETE` / `GRAPHQL` was selected
└── hooks/
└── {formHookFileName}.ts ❇️ # <- If `formHook` selected, e.g. `useResolverFormState.ts`