nicolasdao / graphql-s2s

Add GraphQL Schema support for type inheritance, generic typing, metadata decoration. Transpile the enriched GraphQL string schema into the standard string schema understood by graphql.js and the Apollo server client.
Other
187 stars 15 forks source link

This example transpiles wrong #25

Closed ProphetDaniel closed 5 years ago

ProphetDaniel commented 5 years ago

Using "graphql-s2s": "^0.17.2", From:

enum OperationType {
  INVEST
  WITHDRAW
}
type Transaction {
  id: ID! @unique
  user: User!
  date: DateTime!
  operationType: OperationType!
  amount: Float!
  tx: String
  notes: String
}

enum Role {
  ADMIN
  USER
}

type User {
  id: ID! @unique
  email: String! @unique
  name: String!
  roles: [Role!]!
  referrer: User @relation(name: "UserReferrerRelation")
  referrals: [User!]! @relation(name: "UserReferralsRelation")
  password: String!
  rate: Float!
}

To:

type Transaction { 
    id: ID! @unique
    user: User!
    date: DateTime!
    operationType: OperationType!
    amount: Float!
    tx: String
    notes: String
}
type User { 
    id: ID! @unique
    email: String! name: String!
    roles: [Role!]!
    referrer: User @relation(name: "UserReferrerRelation")
    referrals: [User!]! password: String!
    rate: Float!
}
enum OperationType { 
    INVEST
    WITHDRAW
}
enum Role { 
    ADMIN
    USER
}

@relation directive from referrals field at User type is lost in the transpilation process.

nicolasdao commented 5 years ago

Hi @ProphetDaniel ,

Thanks a lot for reporting that issue. I've just fixed it. Install the latest version (0.17.4) and let me know if that fixes your problem.

Let me know if there is else I can do to make this lib better.

Cheers,

Nic