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

Self relation graphql module generation problem #149

Closed
alaarihan opened this issue Nov 3, 2020 · 4 comments · Fixed by #150
Closed

Self relation graphql module generation problem #149

alaarihan opened this issue Nov 3, 2020 · 4 comments · Fixed by #150
Assignees
Labels
bug Something isn't working
Projects

Comments

@alaarihan
Copy link
Contributor

Hi,

While I'm creating a self relations in a module, pal g made a wrong import from the module to its self, this confusion happened because the module has relations to its self:

model Category {
  id        Int        @id @default(autoincrement())
  name      String
  parentId  Int?
  parent    Category?  @relation("CategoryTree", fields: [parentId], references: [id])
  children  Category[] @relation("CategoryTree")
  createdAt DateTime   @default(now())
  updatedAt DateTime   @updatedAt
}

The generated code was like this:

import { GraphQLModule } from '@graphql-modules/core'
import typeDefs from './typeDefs'
import resolvers from './resolvers'
import { addSelect } from '../common/addSelect'
import { CommonModule } from '../common/common.module'
import { CategoryModule } from '../Category/Category.module'

export const CategoryModule = new GraphQLModule({
  name: 'Category',
  typeDefs,
  resolvers,
  imports: [CommonModule, CategoryModule],
  resolversComposition: {
    Query: [addSelect],
    Mutation: [addSelect],
  },
})

as you see the module name is CategoryModule and it contain an import to CategoryModule in the same time

@AhmedElywa AhmedElywa self-assigned this Nov 3, 2020
@AhmedElywa AhmedElywa added the bug Something isn't working label Nov 3, 2020
@AhmedElywa AhmedElywa added this to To do in Dashboard via automation Nov 3, 2020
@AhmedElywa
Copy link
Collaborator

Thanks for the report will work on it

@AhmedElywa
Copy link
Collaborator

If you have time and want to try solving it you can take a look here

if (!modules.includes(dataField.type + 'Module')) {

@alaarihan
Copy link
Contributor Author

Yeah sure, I just want to know how can I test the changes that I will make?

@AhmedElywa
Copy link
Collaborator

You can make any folder in https://github.com/paljs/prisma-tools/tree/master/packages/generator/__tests__ path and take nexus-prisma as an example.

to run the generator just do node index.js command inside your folder

Dashboard automation moved this from To do to Done Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Dashboard
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants