Separate generated services and SDL files from custom ones

Thank you @dthyresson, I checked again with GraphQL client and it seems I found a bug in the Redwood plugin.

Here’s my folder and file structure and what I tried:

Custom schema definition is in subfolder to keep it separated from generated ones it’s located in
[root]/api/src/graphql/custom/usersCustom.sdl.ts:

It defines usersBy field since users is already taken by generated one and overriding is not possible as far as I know.

export const schema = gql`
  type Query {
    usersBy(firstName: String): [User!]! @requireAuth
  }
`;

If there is no service Redwood (plugin) will report SERVICE_NOT_IMPLEMENTED error on that line.

The service is defined as separate file in:
[root]/api/services/custom/usersCustom.ts

import type { QueryResolvers } from 'types/graphql';

import { db } from 'src/lib/db';

export const usersBy: QueryResolvers['usersBy'] = ({ firstName }) => {
  return db.user.findMany({
    where: {
      firstName: {
        contains: firstName,
        mode: 'insensitive',
      },
    },
  });
};

As long as I export variable usersBy it will work actually, BUT the plugin still reports the error about service not being implemented. I trusted it too much and probably had errors while testing in the beginning.

Some more context for those starting journey with Redwood and services:

export const usersBy: QueryResolvers['usersBy'] = ({ firstName }) => { ... }
  1. exported variable MUST be named just like the query in SDL
    @dthyresson Q1: is there a way to manually map the SDL to service?

  2. QueryResolvers will be generated with types (yarn rw g types) and should reference name of the SDL query/field so that parameters of the query are known by TypeScript (for autocomplete etc.)

  3. service file can be located in any depth in folder structure inside services folder.

The error is still shown in VS Code that service is not implemented.

@dthyresson Please correct me if I’m wrong about the above.

Q4: I also see that when generating SDL sometimes (cant pinpoint why yet) ModelResolvers get deleted completely. Maybe it’s when I generate service on it’s own separately from SDL (not sure) or there are “errors” in SDL(?). I just now regenerated user with SDL and it would add UserResolvers that were not there a sec ago at all. Why would that happen @dthyresson ?

Offtopic:

@dthyresson I also have a request (humble one :slight_smile: ) I have posted my problems with integrating custom components (for MultiSelect) is there someone I could ask for help from the team to take a look? I know you have little time and I do appreciate help but that thing is driving me crazy since last few days and I’m stuck.
ex. Integrate custom select (react-select or other) as custom Redwood component

I did study the docs, used react-hook-form register function but had no luck, either API failed or components are not sending data at all.

I have also seen that Mantine is integrated and awaits release, when could we expect that and is there a code in RW that would show how such components should be integrated?