graphql-mesh: snakeCase does not properly handle "k8sClusterInstance"

Describe the bug

The snakeCase transformation converts k8s to k8_s

To Reproduce Steps to reproduce the behavior:

sources:
  - name: api
    handler:
      postgraphile:
        schemaName:
          - public
        options:
          dynamicJson: true
          enhanceGraphiql: true
          allowExplain: true
          defaultPaginationCap: 10
        appendPlugins:
          - "postgraphile-federation-plugin"
          - "postgraphile-plugin-connection-filter"
          - "@graphile/pg-aggregates"
    transforms:
      - namingConvention:
          fieldNames: snakeCase

Expected behavior

The snakeCase transformation should special-case ^[a-zA-Z][0-9]{,2}s

Environment:

  • OS: macOS BigSur
  • @graphql-mesh/cli: ^0.45.0,
  • @graphql-mesh/postgraphile: ^0.17.8,
  • @graphql-mesh/transform-filter-schema: ^0.14.6,
  • @graphql-mesh/transform-naming-convention: ^0.8.6,
  • @graphql-mesh/transform-prefix: ^0.9.6,
  • NodeJS: v12.22.2

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19

Most upvoted comments

@charlypoly Thanks for noticing the typo and the details about the naming-convention transformer. Sorry, I should have realized that typo 😐 You solution does indeed transform the field but it still breaks the schema. It’ll work for one type but it destroys the fields for all the other types, making the schema unusable.

This bug has been fixed in @graphql-mesh/transform-rename@0.11.9

@charlypoly Thanks for noticing the typo and the details about the naming-convention transformer. Sorry, I should have realized that typo 😐 You solution does indeed transform the field but it still breaks the schema. It’ll work for one type but it destroys the fields for all the other types, making the schema unusable.

@nicerobot You found a new bug - on the rename transformer this time, I did a PR to fix it: https://github.com/Urigo/graphql-mesh/pull/3480 I’ll keep you updated!

@nicerobot

  • Would you mind giving me a few pointers on what you did to narrow this down? I’m quite new to this stack (and I’ve been out of the JS world for a long time) so I felt I was all over the place trying to track this down, not knowing where to start.

I am actually onboarding on The Guild team and especially on GraphQL Mesh project. I already used a lot GraphQL Mesh in a side project and read most of the docs, so I got a big picture of how it works. Following this ā€œbig pictureā€, I started by checking at the naming-convention transformer, by doing a failing unit test, which concluded that the issue was not from the transformer. After your feedback that the issue was still here, I started to look at other sources of the bug, always trying to look at narrowed parts of the code-base. Here, I felt that the issue could be from the Postgraphile source, so I started to look at Postgraphile logic around GraphQL fields inflectors. This is where I realized that the ā€œissueā€ was not an issue but a normal behavior from Postgraphile through lodash helper (camelCase). So, in short, I isolated part of the codebase, one by one, in order to narrow down the bug.

  • I wonder if i can disable the camelCase conversion Postgraphile using an inflection like this? That seems like exactly what I want.

I guess you could define and publish your own plugin as explained in both GraphQL Mesh and PostGraphile docs: https://www.graphql-mesh.com/docs/handlers/postgraphile#external-plugins-eg-federationplugin-pgmanytomanyplugin-postgisplugin

However, I am not fluent in Postgraphile…

Is that an issue related to GraphQL Mesh? Apollo Server/Federation is owned and maintained by https://www.apollographql.com, not by The Guild šŸ™‚