Custom schema as workaround to plurals issue

Let’s say I have a Parse class called “Media”. The find query for this class will not be added to the auto-generated GraphQL schema, because it collides with the get query:
warn: Query media could not be added to the auto schema because it collided with an existing field.

The reason is that the auto-generation uses pluralization for the find query, but the plural of “Media” is “Media”. This whole thing could be fixed (#6218) but I didn’t succeed in doing that yet. Now I’m looking for a workaround.

In the GraphQL guide under Adding Custom Schema there is some documentation, which isn’t very helpful if you’re also still learning how GraphQL works. My goal is clear: I want to add custom schema so that when I write “mediaObjects” in my GraphQL query, a find query on the “Media” class is executed.

I am able to add custom schema, but I don’t know what it should be…

# schema.graphql
extend type Query {
  mediaObjects: [Media]! @resolve(to: "Media")

How should the query be extended for that purpose?
Should we add this troubleshoot to the documentation?

1 Like

May be we can fix this one by forcing the “s” at the end of the word if after pluralize the word is the same. It will patch majority of these use cases even if the typo is not correct. I think it’s better for DX to just force an “s” than requesting the developer to re map the type or change the whole type name.

@zadek the PR to force the S seems to be an easy one, are you open to give it a try ? I will be happy to review it or help you to ship this one

I did that change already in a branch in my fork. I appended “Objects” instead of just “s”, because some classes might already be plural like “Analytics” so I thought “AnalyticsObjects” would be nicer than “Analyticss”. I know that it’s bad practice to call classes in Plurals but 2015 me did not know that haha.

So I did the change, but the problem is that I can’t test it. I am stuck trying to set up the development environment. I wanted to link the cloned parse-server repository with npm link, which works, but when I then try to run the server, other dependencies like parse-server-mandrill-adapter break since they would also need to reference the local version I guess. It’s just all very obscure to me. I could just set up a completely new project for developing and testing. Is that what most people do? I thought it would be better to use my usual development/staging project for testing new things as well.

Well I guess then I’ll give that a try next. But is there really no workaround using the custom schema?