Expand the namingConvention to allow for overriding input types #8197
-
|
Currently we use the It would be really useful if the naming conventions worked for both output and input types. Making the entire round trip seamless. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
|
Hi @Soviut! Could you provide an example? If I understand well, your issue is that you have to manually convert data keys to snakecase when sending it to the API? |
Beta Was this translation helpful? Give feedback.
-
|
@charlypoly That's correct; we need to use snakecase-keys to turn our camelcase JS objects back into snake case before we pass them to our mutation variables. Our Postgres database uses snake case. We wrap it in Hasura to generate our graphql schema, so it uses snake case as well in the schema. We're using the vue-apollo plugin so performing a mutation looks something like the following. import snakecaseKeys from 'snakecase-keys'
const contact = {
firstName: 'Joe',
lastName: 'Blow',
emailAddress: '[email protected]',
}
const { mutate: importClient } = useImportClientMutation({})
// need to convert to snake case here on the `client` variable to match the input type that has snakecase
await importClient({ client: snakecaseKeys(contact) }) |
Beta Was this translation helpful? Give feedback.
-
|
@charlypoly To clarify, I'm not looking to change my schema (which is snake case), I simply would like some kind of transform step for query/mutation variables. Basically, the inverse of what naming conventions are doing for output. In my prior example const contact = {
firstName: 'Joe',
lastName: 'Blow',
emailAddress: '[email protected]',
}
await importClient({ client: snakecaseKeys(contact) })I would expect await importClient({ client: contact })Essentially, move that transformation step into some kind of inverse of naming convention. |
Beta Was this translation helpful? Give feedback.
-
|
Putting the answer here for visibility:
|
Beta Was this translation helpful? Give feedback.
Putting the answer here for visibility: