In REST, PUT is used to update or replace an entire resource. POST is usually for creating, GET for reading, and DELETE for removing.
name and age fields of a user, what will the response JSON look like?query { user(id: "1") { name age } }GraphQL responses wrap the requested data inside a data object. Only the requested fields appear. Here, name and age are included, but not id.
const express = require('express'); const app = express(); // Which option is correct?
GraphQL servers typically accept POST requests at a single endpoint, often '/graphql'. Using app.post matches this pattern.
After a successful deletion, REST APIs commonly return 204 No Content to indicate success without a response body.
Cannot read property 'data' of undefined. Which code snippet is the likely cause?app.post('/graphql', async (req, res) => { const result = await graphql(schema, req.body.query); res.json(result.data); });
The error occurs because result might be undefined if the promise rejects or the call fails. The code should handle errors and check if result exists before accessing result.data.
