Answer the question
In order to leave comments, you need to log in
How to connect graphQL with front?
Good afternoon!
There is a simple server on Node JS and a Database on Mongo Atlas, GraphQL is used for queries.
How can I link a ready front (html, css, native__js) to the server?
Answer the question
In order to leave comments, you need to log in
Igor Myasnikov , so, well, the
query itself is { operationName, query, variables }
For multipart { operations, map }
const query = `
query($id: Int!) {
user(id: $id) {
name
}
}
`;
fetch('https://gql-placeholder.herokuapp.com/graphql', {
method: 'POST',
headers: {
'content-type': 'application/json',
},
// credentials: 'include',
body: JSON.stringify({
operationName: null,
query,
variables: {
id: 1,
},
}),
})
.then((r) => r.json())
.then(console.log);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question