File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1
1
2
2
# Node GraphQL
3
3
4
- GraphQL server.
4
+ GraphQL server with CORS .
5
5
6
6
## Setup
7
7
17
17
18
18
## Usage
19
19
20
+ With curl:
21
+
20
22
```
21
23
$ curl -d '{ "query": "{ pet(id: 0) { name }}" }' `up url`?pretty
22
24
```
25
+
26
+ With ` fetch() ` in the browser:
27
+
28
+ ``js
29
+ const body = JSON.stringify({
30
+ query: `query {
31
+ pet(id: 2) {
32
+ name
33
+ }
34
+ }`
35
+ })
36
+
37
+ const res = await fetch('http://localhost:3000 ', {
38
+ headers: { 'Content-Type': 'application/json' },
39
+ method: 'POST',
40
+ body
41
+ })
42
+
43
+ console.log(res)
44
+ console.log(await res.json())
45
+ ```
46
+
47
+ See the [CORS](https://up.docs.apex.sh/#configuration.cross_origin_resource_sharing) second of the documentation for details.
Original file line number Diff line number Diff line change 1
1
{
2
- "name" : " app"
2
+ "name" : " app" ,
3
+ "cors" : {
4
+ "enable" : true ,
5
+ "debug" : true
6
+ }
3
7
}
You can’t perform that action at this time.
0 commit comments