Extending New...[Model] scaffold with data fetching

Hi there,

so again I am continuing exploring Redwood and it looks nice but I still have some concerns and questions about “correct” way of doing things.

I am currently trying to reuse as much from RW as possible hence I am modifying scaffolds as simple admin CRUD panel.

When creating scaffold for any Model the New[Model] is created as component opposed to Edit[Model] which is a Cell.

Since I have related fields that are required in New[Model] I created a cell sine that is RW way for data fetching (as stated by the tutorial)

Then I pass the data from Success to New[Model] component (that I modified to accept data as props).

All works as expected and there was no need to update anything else (like types etc.) but I want to make sure if this is a correct way of doing things or should it be done differently?

In the end code looks somewhat like:

Code below shows only the ‘diff’ for mentioned files from generated by RedwoodJS

Changes in New[Model].tsx component to accept relatedData as props so it’s available when creating New element.

...
const NewModel = ({ relatedData }) => {
...

return (
...
<ModelForm
          onSave={onSave}
          relatedData={relatedData}
          loading={loading}
          error={error}
        />
...
}

Changes to NewModelCell:

export const QUERY = gql`
  query FindAllRelatedData {
    relatedData{
      id
      title
    }
  }
...
export const Success = ({
  relatedData,
}: 
...
  return <NewModel relatedData={relatedData} />;
};
`;

And finally the Page needed to be changed to use NewModelCell instead of NewModel:

import NewModelCell from 'src/components/Admin/Model/NewModelCell';

const NewModelPage= () => {
  return <NewModelCell />;
};

export default NewModelPage;

In the end the question is: Is this correct approach or should I do this differently?

PS. cells do not accept prefixes and error out when trying to generate the, ex. yarn rw g cell Admin/[Model]/New[Model] and need to be moved from root folder structure when created - is this a bug?