I have a graphQL type
defined in a .graphql
file for a nestjs schema first application. The type is:
type address {
id: String
Title: String
Url: String
}
Now, using nestjs I have a resolver function as
@Query('address')
async getAll(): Promise<any> {
return await this.addressService.getAll();
}
The result from the await this.addressService.getAll()
is an array of objects with the properties having _
in them like:
[
{
id: 1,
address_title: 'title',
address_url: 'url'
}
]
I am also using @nestjs/graphql
library for the @Query
, @ResolveField
and such. My problem is, how can I map the response properties to the graphql properties that I have written as a SDL in the .graphql
file in nestjs framework? Is there any way we can map the graphql query properties to the result properties using nestjs?
I looked at the graphql alias, also mentioned here but that is not useful for me. Any help on this is highly appreciated.