$ npm install --legacy-peer-deps# development
$ npm run start
# watch mode
$ npm run start:dev# unit tests
$ npm run testThis documentation provides guidance on how to interact with the GraphQL API for a system managing Users and Products. The API allows you to insert data into Users and Products entities using GraphQL mutations and to query users along with their associated product information.
Before you begin, ensure that you have the GraphQL endpoint URL provided by the server. This endpoint is used for all GraphQL queries and mutations.
All GraphQL requests should be sent to the following endpoint once the app is running:
POST http://localhost:3000/graphqlTo add a new user, you will use a GraphQL mutation. Here is a sample mutation request:
mutation {
createOneUser(input: {
name: "John Johnson",
email: "[email protected]",
age: 29
}) {
id
name
email
age
}
}
To add a new product, use a mutation structured as follows:
mutation {
createOneProduct(input: {
product: {
name: "Newspaper",
price: 9.99
}
}) {
id
name
price
}
}To query users and their associated products listed under the "order" field, use the following query structure:
query GetUsersWithOrders {
getUsersWithOrder {
id
name
email
age
order {
id
name
price
}
}
}This query will return a list of users along with their orders, including the details of each product in their orders.
{
"data": {
"getUsersWithOrder": [
{
"id": "1",
"name": "John Doe",
"email": "[email protected]",
"age": 30,
"order": [
{
"id": "101",
"name": "Product Name",
"price": 99.99
}
// ... more products
]
}
// ... more users
]
}
}