Resolver:
func (r *queryResolver) GetProducts(ctx context.Context) ([]*models.Product, error) {
products := []*models.Product{
{
ID: "1",
Name: "Vingate Sofa",
Image: "src/assets/images/placeholderimage.png",
Category: "Furniture",
Introductiondate: "2023-05-08",
Subcategory: "Sofas",
Views: 50,
Metadata: []*models.MetaData{
{
Name: "Material",
Values: []string{"Fabric", "Wood"},
},
{
Name: "Color",
Values: []string{"Gray", "Black", "Red"},
},
{
Name: "Type",
Values: []string{"Sleeper", "Sectional"},
},
{
Name: "Style",
Values: []string{"Contemporary", "Traditional"},
},
},
},
{
ID: "2",
Name: "Vintage Table",
Image: "src/assets/images/placeholderimage.png",
Category: "Furniture",
Introductiondate: "2023-05-08",
Subcategory: "Tables",
Views: 30,
Metadata: []*models.MetaData{
{
Name: "Material",
Values: []string{"Wood", "Metal"},
},
{
Name: "Color",
Values: []string{"Brown", "Black", "Silver"},
},
{
Name: "Type",
Values: []string{"Coffee", "End", "Console"},
},
{
Name: "Style",
Values: []string{"Modern", "Rustic"},
},
},
},
}
return products, nil
}
Response:
{
"data": {
"getAllBlogs": [
{
"id": "1",
"image": "https://example.com/blog1.jpg",
"category": [
"Technology",
"Productivity"
],
"postdate": "22/3/2024",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus.",
"views": 100
},
{
"id": "2",
"image": "https://example.com/blog2.jpg",
"category": [
"Health",
"Fitness"
],
"postdate": "22/3/2024",
"content": "",
"views": 200
}
]
}
}
Schema:
type MetaData {
name: String!
values: [String!]!
}
type Product {
id: ID!
name: String!
image: String!
category: String!
introductiondate: String!
subcategory: String!
metadata: [MetaData!]!
views: Int!
}
input NewMetaData {
name: String!
values: [String!]!
}
input NewProduct {
id: ID!
name: String!
image: String!
category: String!
introductiondate: String!
subcategory: String!
metadata: [NewMetaData!]!
views: Int!
}
Golang GplGen returning Empty metadata array in response. Ihave given my resolver, response, Schema parts. Golang GplGen returning Empty metadata array in response. Ihave given my resolver, response, Schema parts. Golang GplGen returning Empty metadata array in response. Ihave given my resolver, response, Schema parts.