Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Conveyor-admin not parsing the correct type for dropdown list of related records #7

Open
alian-0 opened this issue Aug 6, 2024 · 1 comment

Comments

@alian-0
Copy link

alian-0 commented Aug 6, 2024

When trying to create a new record within conveyor, if selecting a related record through the built-in dropdown feature, a 400 error occurs if the name of the field doesn't exactly correspond to the list that needs to be queried.

For example, if there's a relation between a record "example" and "platform_area_type," but the field is named "area_type" in "example," (the model works fine with this implementation) the dropdown will parse the list of "area_type" as "area_type_list" rather than "platform_area_type_list," the actual list that needs to be queried.

The query works as expected in GraphiQL once "area_type" is changed to "platform_area_type."

@apglenister
Copy link

apglenister commented Aug 14, 2024

I believe Conner and I identified where this error is occurring:

const onOpenFieldSelect = (model: string) => {
It looks like the modelName argument is just the name of the field, so the query looks for values based on ${fieldName}_list. We would want to change it to something like this instead:

const onOpenFieldSelect = (field: string) => {
   const model = transformToModelName(field.type);
   return selectOptionMutateAsync(model).then((data: any) => {
     return data.items.map((item: any) => ({
       label: item.id,
       value: JSON.stringify(item.id),
     }));
   });
 };

where the function trandformToModelName would take the type of the field and identify the related model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants