-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
GraphQL auto schema findQuery is not generated for classes named in plural #6218
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
Comments
Yes if your collection is named in plural the I will take a look to our plural generation to check if we can add an auto renaming (plural to single) on plural classes |
I think 'depluralizing' won't work in 100% cases. Linguistic approach should be 'best effort' for nice readability rather a strict rule. There are other languages and letters combinations that will mislead english 'pluralizer' causing unexpected behavior. In case when pluralize |
@BufferUnderflower thanks for the PR ! 😄 |
Pardon me opening closed issue How can I use auto schema for dockerized parse and prevent this message: |
Hi @nasermirzaei89, what is your parse classes names ? |
Media |
You only have on class into your app ? Are you sure to run the latest version of the parse docker image ? Can you provide your command line / config that you use to start the server ? |
the problem is when the auto schema generates. for example for server:
image: parseplatform/parse-server:4.2.0
ports:
- 1337:1337
depends_on:
- mongo
environment:
PARSE_SERVER_APPLICATION_ID: appId
PARSE_SERVER_MASTER_KEY: masterKey
PARSE_SERVER_DATABASE_URI: mongodb://mongo/xonyagar
PARSE_SERVER_JAVASCRIPT_KEY: javascriptKey
PARSE_SERVER_REST_API_KEY: restApiKey
PARSE_SERVER_MAX_UPLOAD_SIZE: 100mb
PORT: 1337
PARSE_SERVER_HOST: 0.0.0.0
PARSE_SERVER_MOUNT_PATH: /parse
PARSE_SERVER_MOUNT_GRAPHQL: 1
PARSE_PUBLIC_SERVER_URL: http://localhost:1337/parse |
This is a part of auto generated graphql schema: ...
"The health query can be used to check if the server is up and running."
health: Boolean!
"The link query can be used to get an object of the Link class by its id."
link(
"This is the object id. You can use either the global or the object id."
id: ID!,
"The read options for the query to be executed."
options: ReadOptionsInput
): Link!
"The links query can be used to find objects of the Link class."
links(
after: String,
before: String,
first: Int,
last: Int,
"The read options for the query to be executed."
options: ReadOptionsInput,
"The fields to be used when sorting the data fetched."
order: [LinkOrder!],
"This is the number of objects that must be skipped to return."
skip: Int,
"These are the conditions that the objects need to match in order to be found."
where: LinkWhereInput
): LinkConnection!
"The media query can be used to get an object of the Media class by its id."
media(
"This is the object id. You can use either the global or the object id."
id: ID!,
"The read options for the query to be executed."
options: ReadOptionsInput
): Media!
... as you see media list isn't generated because of conflict in name with media get! but, for example links and link generated successfully! |
Oh I see, the pluralize system will work in 97% of use cases I guess ( I have many parse server with hundred of classes and I did not encounter this type of error) Did you take a look on the pull request linked above to activate aliases and get rid off this issue ? I see 2 solutions here for your use case:
What do you think about this ? |
I already used the second solution |
I think your suggestion is interesting, we have many exemple on how to support option via Env vars. Since we are in open source project, each addition is welcome. I invite you to create a parse-server fork and may be start a pull request ? :) |
I interested in contributing to projects I use. I will do that for dear parse community as soon as possible. |
@nasermirzaei89 I am running into the same problem. Many of my classes have the suffix If we don't fix this, people will continue running into this issue in the future. Since a migration is not always possible, that can be pretty discouraging. I think your idea with the environment variables is a good fix for when people run into issues, but it would of course be better if they'd just not run into them. What prevents us from adding a suffix to the name if the singular and plural are identical? Something like "All", "Items" or "Records"? That could still clash with another name but it's much less likely to happen. |
I think this idea makes sense. I am re-opening the issue. Would you be willed to tackle this one? |
…l and singular are identical (parse-community#6218)
I tried making my first contribution on the weekend, but couldn't manage to test everything locally. I'm happy to give it another shot though. @davimacedo, maybe you can help me out in setting up the development environment? I already asked in Slack in the #parse-server channel: https://parseopensource.slack.com/archives/C0TS8BRRV/p1604763010023300 |
Just answered you in slack. Take a look if that helps and let me know. |
Issue Description
GraphQL auto schema gets generated only partially for classes named in plural.
get
seems to work fine, butfindQuery
is not available at all.Steps to reproduce
Create a collection named in plural, eg
Data
,UserData
,Comments
etcExpected Results
Be able to issue find GQL query
Actual Outcome
Schema generated only partially
Environment Setup
Logs/Trace
n/a
I understand this is a bad practice to name collection in plural (i have some legacy code), but for sure it's possible to handle by adding a few lines of code in generator for such edge cases. (when
pluralize
's output equalsclassName
)I'm looking forward to add a PR for that but i'm not sure what would be a better way to name it.
commentses
/comments_
/commentss
/ ... ?The text was updated successfully, but these errors were encountered: