Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

type with name "News" cannot be deployed #1772

Closed
attilah opened this issue Jan 30, 2018 · 6 comments
Closed

type with name "News" cannot be deployed #1772

attilah opened this issue Jan 30, 2018 · 6 comments

Comments

@attilah
Copy link

attilah commented Jan 30, 2018

Current behavior

I wanted to create a type named News but an error was returned

Reproduction

try to deploy this datamodel

type News {
  id: ID! @unique
}

Error:

ERROR: All fields within 'Query' type should have unique names! Non-unique fields: 'news'.

{
  "errors": [
    {
      "requestId": "api:api:cjd18y9me003d0138ifqm95q9",
      "message": "All fields within 'Query' type should have unique names! Non-unique fields: 'news'."
    }
  ],
  "status": 500
}

Expected behavior?

News type created.

@johannpinson
Copy link
Contributor

Same thing, but the model seems to be created well.
Just the generation of the schema looks fail (I check my RDS and the table "News" is created well)

capture d ecran 2018-03-13 a 16 13 50

@johannpinson
Copy link
Contributor

Related to #48

@marktani
Copy link
Contributor

Yup, the issue here is that the plural form of News will be News - so both queries for many news - news: [News!]! - and single news - news: News are called news, leading to the name clash.

@johannpinson
Copy link
Contributor

Yes I see some issues about it (#48 and #253 in particular)

And specially one about the directive @queries: https://github.com/graphcool/prisma/issues/1342
This issue is closed but doesn't to work, any info about it?

Another solution will be about create special case for the plural detection here:
https://github.com/graphcool/prisma/blob/d20b3674e241c2068f6560ca20cf908f667def61/server/servers/api/src/main/scala/com/prisma/api/schema/SchemaBuilder.scala#L252-L259

And evo-influctor already detect some case:
https://github.com/atteo/evo-inflector/blob/64ab921bbdeb797e6aa6469eb7a53320b505221a/src/main/java/org/atteo/evo/inflector/English.java#L146

One possibility will to detect when evo return the same string as the plural and so change the rule by adding the all before, like on graph.cool
In this case, we will have a query named allNews

What do you think about this solution?

@attilah
Copy link
Author

attilah commented Mar 13, 2018

using all prefix for the collection, or an Item (NewsItem) suffix for the single ones is a good way, whatever fix you decide I think this option should be handed to the developer and make it a configurable option.

As a personal preference I like the News and NewsItem more.

@marktani
Copy link
Contributor

Closing as duplicate of #2659.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants