xxxxxxxxxx
@Resolver()
export class ProductsResolver {
@Query(() => [Product])
async products(
@Info() info
) {
// Method 1 thanks to @pooya-haratian.
// Update: use this method; read below article to understand why.
let keys = info.fieldNodes[0].selectionSet.selections.map(item => item.name.value);
// Method 2 by me, but I'm not sure which method is best.
// Update: don't use this; read below article to understand why.
let keys = info.operation.selectionSet.selections[0].selectionSet.selections.map(field => field.name.value);
return keys;
}
}