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

Handling noncount nouns / no plural forms #117

Open
mwillbanks opened this issue Sep 15, 2022 · 0 comments
Open

Handling noncount nouns / no plural forms #117

mwillbanks opened this issue Sep 15, 2022 · 0 comments

Comments

@mwillbanks
Copy link
Contributor

When using typegraphql (but also would likely be an issue when nexus), when using noncount nouns or a resource that does not have a plural form (i.e. equipment) the queries for GET_LIST and GET_ONE will be the same thus causing a conflict.

typegraphql handles this by exporting these differently instead of having a singular equipment which would be duplicated, it names the queries differently:

findManyEquipment
findUniqueEquipment

In this case, it would be somewhat easy to change the underlying query logic that is inside of the makeIntrospectionOptions to handle this based on the query dialect for now (which already exists). However, since other methods might exist it might be better to be able to pass in the query resolver name through the useDataProvider options.

As an example:

useDataProvider({
  clientOptions: { uri: "/graphql" },
  resourceViews: {
    Equipment: {
      resource: "Equipment",
      operationNames: {
        one: 'findUniqueEquipment',
        many: 'findManyEquipment',
      }
    }
  }
});
mwillbanks added a commit to mwillbanks/ra-data-prisma that referenced this issue Sep 15, 2022
Provide a way to override operation names to handle edge cases where the resource name is not the actual operation or the operations were customized

```
useDataProvider({
  operationNames: {
    RESOURCE_NAME: {
      create: "myCreateOperation",
      update: "myUpdateOperation",
      delete: "myDeleteOperation",
      one: "myOneOperation",
      many: "myManyOperation"
    }
  }
});
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant