diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40f4b045815e..101da83c8228 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -238,11 +238,6 @@ jobs: yarn rw test web --no-watch working-directory: ${{ steps.setup_test_project.outputs.test_project_path }} - - name: Run "rw type-check" - run: | - yarn rw type-check - working-directory: ${{ steps.setup_test_project.outputs.test_project_path }} - - name: Run "rw check" run: | yarn rw check @@ -291,6 +286,16 @@ jobs: yarn rw g page ciTest working-directory: ${{ steps.setup_test_project.outputs.test_project_path }} + - name: Run "g sdl" + run: | + yarn rw g sdl userExample + working-directory: ${{ steps.setup_test_project.outputs.test_project_path }} + + - name: Run "rw type-check" + run: | + yarn rw type-check + working-directory: ${{ steps.setup_test_project.outputs.test_project_path }} + - name: Throw Error | Run `rw g sdl ` run: | yarn rw g sdl DoesNotExist diff --git a/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap b/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap index 8ceebf4b851a..b9ae584a55ce 100644 --- a/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap +++ b/packages/internal/src/__tests__/__snapshots__/graphqlCodeGen.test.ts.snap @@ -9,8 +9,8 @@ export type Exact = { [K in keyof T]: T[K] export type MakeOptional = Omit & { [SubKey in K]?: Maybe }; export type MakeMaybe = Omit & { [SubKey in K]: Maybe }; export type ResolverFn = ( - args: TArgs, - obj: { root: TParent; context: TContext; info: GraphQLResolveInfo } + args?: TArgs, + obj?: { root: TParent; context: TContext; info: GraphQLResolveInfo } ) => Promise> | Partial; export type RequireFields = Omit & { [P in K]-?: NonNullable }; /** All built-in and custom scalars, mapped to their actual values */ @@ -78,11 +78,7 @@ export type Todo = { export type ResolverTypeWrapper = Promise | T; - -export type ResolverWithResolve = { - resolve: ResolverFn; -}; -export type Resolver = ResolverFn | ResolverWithResolve; +export type Resolver = ResolverFn; export type SubscriptionSubscribeFn = ( parent: TParent, diff --git a/packages/internal/src/generate/graphqlCodeGen.ts b/packages/internal/src/generate/graphqlCodeGen.ts index cca016df11c2..d69f7ce8f830 100644 --- a/packages/internal/src/generate/graphqlCodeGen.ts +++ b/packages/internal/src/generate/graphqlCodeGen.ts @@ -137,6 +137,7 @@ function getPluginConfig() { const pluginConfig: CodegenTypes.PluginConfig & typescriptResolvers.TypeScriptResolversPluginConfig = { + makeResolverTypeCallable: true, namingConvention: 'keep', // to allow camelCased query names scalars: { // We need these, otherwise these scalars are mapped to any @@ -152,10 +153,10 @@ function getPluginConfig() { // prevent type names being PetQueryQuery, RW generators already append // Query/Mutation/etc omitOperationSuffix: true, - + showUnusedMappers: false, customResolverFn: `( - args: TArgs, - obj: { root: TParent; context: TContext; info: GraphQLResolveInfo } + args?: TArgs, + obj?: { root: TParent; context: TContext; info: GraphQLResolveInfo } ) => Promise> | Partial;`, mappers: prismaModels, contextType: `@redwoodjs/graphql-server/dist/functions/types#RedwoodGraphQLContext`,