ermadmi78 / kobby

Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Apache License 2.0
83 stars 4 forks source link

Kobby does not escape Kotlin keywords in fields and argument names #17

Closed leadmanager closed 2 years ago

leadmanager commented 2 years ago

there are graphql schemas that has search parameters named "is","it" etc... the code generator generate them like this: TxSubtypeSelector( it.is, it.not, it.in, it.notIn )

should be: TxSubtypeSelector( it.``is``, it.not, it.``in``, it.notIn )

leadmanager commented 2 years ago

can you please delete this issue, used work account and not personal.. will post it again with mine

ermadmi78 commented 2 years ago

Reproduced. I'll fix it soon.

ermadmi78 commented 2 years ago

Testcase:

directive @primaryKey on FIELD_DEFINITION
directive @required on FIELD_DEFINITION
directive @default on FIELD_DEFINITION
directive @selection on FIELD_DEFINITION

type Query {
    escapes(do: Int! = 0, by: Int! = 100): [Escape!]!

    escapesSelection(do: Int! = 0, by: Int! = 100): [Escape!]! @selection

    severalPrimaryKeys: SeveralPrimaryKeys
}

type Mutation {
    by(while: EscapeInput): Escape
}

type Subscription {
    by(in: Int): Escape
}

interface IEscape {
    is: String!
    for: Int @required
    points(do: Int! = 0, by: Int! = 100): [Point!]!
}

type Escape implements IEscape {
    if: ID! @primaryKey

    is: String!
    for: Int
    points(do: Int! = 0, by: Int! = 100): [Point!]!
    it: String!
    in : String @default
    val: Point
    var: [Point]
    while: [Point!]!
}

type Point {
    x: Int!
    y: Int!
}

input EscapeInput {
    is: String!
    it: String!
    in : String
}

type SeveralPrimaryKeys {
    if: ID! @primaryKey
    do: String @primaryKey
    while: Int! @primaryKey

    it: String @primaryKey
    other: String @primaryKey
    result: Int! @primaryKey
    block: String @primaryKey
}
ermadmi78 commented 2 years ago

Fixed in release 1.3.1