An example of GraphQL queries/mutations with Node and Express js.
With GraphQL, clients can specify exactly what data they need, and the server responds with only that data, reducing the amount of data transferred over the network.
Rest API Endpoint for get all users: http://localhost:5000/rest/getAllUsers
GraphQL Endpont: http://localhost:5000/graphql
Query for below scenarios:
- Get All Users with query operation
query{ getAllUsers{ id email } }
- Get single user details
query{ findUserById(id:1000){ id firstName lastName email } }
- Create User with mutation operation
mutation{ createUser(firstName:"dhruv",lastName:"darji",email:"dhruv@dhruv.com",password:"password"){ id firstName lastName email } }