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

Trouble with the transformation Rename with fields start by number #2491

Closed
simon-hlx opened this issue Jul 20, 2021 · 2 comments
Closed

Trouble with the transformation Rename with fields start by number #2491

simon-hlx opened this issue Jul 20, 2021 · 2 comments

Comments

@simon-hlx
Copy link

Describe the bug
Hey, I have some trouble with the rename transformation
The situation :
I have a legacy database with some fields start by number. So I got error I do not apply the rename transformation , no problem I am okay with this !
To Reproduce
Steps to reproduce the behavior:
Have a mysql table with two column name start by number and apply this config:
.meshrc.yaml

sources:
  - name: Legacy
    handler:
      mysql:
        host: 127.0.0.1
        port: 3306
        user: POMME
        password: 'FRITE'
        database: scoubidou
    transforms:
      - rename:
          mode: wrap
          renames:
            - from:
                type: Users
                field: 2way_authentication
              to:
                type: Users
                field: two_way_authentication
            - from:
                type: Users
                field: 2way_authentication_token
              to:
                type: Users
                field: two_way_authentication_token
            - from:
                type: UsersOrderByInput
                field: 2way_authentication
              to:
                type: UsersOrderByInput
                field: two_way_authentication
            - from:
                type: UsersOrderByInput
                field: 2way_authentication_token
              to:
                type: UsersOrderByInput
                field: two_way_authentication_token
            - from:
                type: UsersWhereInput
                field: 2way_authentication
              to:
                type: UsersWhereInput
                field: two_way_authentication
            - from:
                type: UsersWhereInput
                field: 2way_authentication_token
              to:
                type: UsersWhereInput
                field: two_way_authentication_token
            - from:
                type: UsersInsertInput
                field: 2way_authentication
              to:
                type: UsersInsertInput
                field: two_way_authentication
            - from:
                type: UsersInsertInput
                field: 2way_authentication_token
              to:
                type: UsersInsertInput
                field: two_way_authentication_token
            - from:
                type: UsersUpdateInput
                field: 2way_authentication
              to:
                type: UsersUpdateInput
                field: two_way_authentication
            - from:
                type: UsersUpdateInput
                field: 2way_authentication_token
              to:
                type: UsersUpdateInput
                field: two_way_authentication_token

The server launch without any exception
And i can query like this :

// just display the id
{
  getUsers(limit: 1){
    id
  }
}

//OR
// just display the id and with filter on the new name
{
  getUsers(where:{two_way_authentication:"2"}){
    id
  }
}

But if i try to display the new field with his new name i have execption

{
  getUsers(limit: 1){
    id
    two_way_authentication_token
  }
}

//OR
{
  getUsers(where:{two_way_authentication:"2"}){
    id
    two_way_authentication_token
  }
}

i got this error:

{
  "errors": [
    {
      "message": "Invalid or unexpected token",
      "path": [
        "getUsers"
      ],
      "name": "GraphQLError",
      "originalError": {
        "name": "SyntaxError",
        "message": "Invalid or unexpected token",
        "stack": [
          "SyntaxError: Invalid or unexpected token",
          "    at new Function (<anonymous>)",
          "    at Object.compileQuery (/PATH/node_modules/graphql-jit/dist/execution.js:70:56)",
          "    at /PATH/node_modules/@graphql-mesh/utils/index.cjs.js:375:42",
          "    at executor (/PATH/node_modules/@graphql-mesh/mysql/index.cjs.js:420:20)",
          "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
          "    at async Promise.all (index 0)"
        ]
      },
      "source": {
        "locationOffset": {}
      },
      "stack": [
        "SyntaxError: Invalid or unexpected token",
        "    at new Function (<anonymous>)",
        "    at Object.compileQuery (/PATH/node_modules/graphql-jit/dist/execution.js:70:56)",
        "    at /PATH/node_modules/@graphql-mesh/utils/index.cjs.js:375:42",
        "    at executor (/PATH/node_modules/@graphql-mesh/mysql/index.cjs.js:420:20)",
        "    at processTicksAndRejections (internal/process/task_queues.js:95:5)",
        "    at async Promise.all (index 0)"
      ]
    }
  ],
  "data": {
    "getUsers": null
  }
}

Environment:

  • OS: macOS Big Sur 11.4
  • @graphql-mesh/...:
    package.json
{
  "dependencies": {
    "@graphql-mesh/cli": "^0.30.2",
    "@graphql-mesh/mysql": "^0.10.9",
    "@graphql-mesh/transform-naming-convention": "^0.6.49",
    "@graphql-mesh/transform-rename": "^0.8.19",
    "graphql": "^15.5.1"
  }
}
  • NodeJS: node v14.17.3 (npm v6.14.13)
@dotansimha
Copy link
Collaborator

dotansimha commented Jul 20, 2021

I'm not sure it's a valid GraphQL AST. Field names cannot start with a number on the AST level:
image

Probably that's why it's failing. @ardatan can take a look in a few days (when he's back from vacation 🌴 )

@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@ardatan
Copy link
Owner

ardatan commented Mar 31, 2023

OpenAPI handler got refactor after this, and it nolonger generates invalid GraphQL fields so this should not be the case anymore. I recommend to use the latest version and try again. let us know if the issue still persists.

@ardatan ardatan closed this as completed Mar 31, 2023
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants