Skip to content

Commit 26c7de8

Browse files
fix sidebar for documentation and /api-v16 (#4331)
Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
1 parent d5c1e8d commit 26c7de8

18 files changed

+58
-41
lines changed

website/next.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
/* eslint-disable camelcase */
22
import path from 'node:path';
3+
import fs from 'node:fs';
4+
5+
const fileContents = fs.readFileSync('./vercel.json', 'utf-8');
6+
const vercel = JSON.parse(fileContents);
37

48
import nextra from 'nextra';
59

@@ -29,6 +33,7 @@ export default withNextra({
2933
});
3034
return config;
3135
},
36+
redirects: async () => vercel.redirects,
3237
output: 'export',
3338
images: {
3439
loader: 'custom',

website/pages/_meta.ts

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
11
const meta = {
2-
index: '',
3-
'-- 1': {
4-
type: 'separator',
5-
title: 'GraphQL.JS Tutorial',
2+
docs: {
3+
type: 'page',
4+
title: 'Documentation',
65
},
7-
'getting-started': '',
8-
'running-an-express-graphql-server': '',
9-
'graphql-clients': '',
10-
'basic-types': '',
11-
'passing-arguments': '',
12-
'object-types': '',
13-
'mutations-and-input-types': '',
14-
'authentication-and-express-middleware': '',
15-
'-- 2': {
16-
type: 'separator',
17-
title: 'Advanced Guides',
18-
},
19-
'constructing-types': '',
20-
'oneof-input-objects': 'OneOf input objects',
21-
'defer-stream': '',
22-
'-- 3': {
23-
type: 'separator',
24-
title: 'FAQ',
25-
},
26-
'going-to-production': '',
276
'api-v16': {
287
type: 'menu',
298
title: 'API',

website/pages/docs/_meta.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const meta = {
2+
index: '',
3+
'-- 1': {
4+
type: 'separator',
5+
title: 'GraphQL.JS Tutorial',
6+
},
7+
'getting-started': '',
8+
'running-an-express-graphql-server': '',
9+
'graphql-clients': '',
10+
'basic-types': '',
11+
'passing-arguments': '',
12+
'object-types': '',
13+
'mutations-and-input-types': '',
14+
'authentication-and-express-middleware': '',
15+
'-- 2': {
16+
type: 'separator',
17+
title: 'Advanced Guides',
18+
},
19+
'constructing-types': '',
20+
'oneof-input-objects': '',
21+
'defer-stream': '',
22+
'-- 3': {
23+
type: 'separator',
24+
title: 'FAQ',
25+
},
26+
'going-to-production': '',
27+
};
28+
29+
export default meta;

website/pages/basic-types.mdx renamed to website/pages/docs/basic-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ console.log('Running a GraphQL API server at localhost:4000/graphql');
112112
113113
If you run this code with `node server.js` and browse to http://localhost:4000/graphql you can try out these APIs.
114114
115-
These examples show you how to call APIs that return different types. To send different types of data into an API, you will also need to learn about [passing arguments to a GraphQL API](/passing-arguments/).
115+
These examples show you how to call APIs that return different types. To send different types of data into an API, you will also need to learn about [passing arguments to a GraphQL API](./passing-arguments).
File renamed without changes.

website/pages/getting-started.mdx renamed to website/pages/docs/getting-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,4 @@ You should see the GraphQL response printed out:
109109

110110
Congratulations - you just executed a GraphQL query!
111111

112-
For practical applications, you'll probably want to run GraphQL queries from an API server, rather than executing GraphQL with a command line tool. To use GraphQL for an API server over HTTP, check out [Running an Express GraphQL Server](/running-an-express-graphql-server/).
112+
For practical applications, you'll probably want to run GraphQL queries from an API server, rather than executing GraphQL with a command line tool. To use GraphQL for an API server over HTTP, check out [Running an Express GraphQL Server](./running-an-express-graphql-server).

website/pages/graphql-clients.mdx renamed to website/pages/docs/graphql-clients.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: GraphQL Clients
44

55
Since a GraphQL API has more underlying structure than a REST API, there are more powerful clients like [Relay](https://facebook.github.io/relay/) which can automatically handle batching, caching, and other features. But you don't need a complex client to call a GraphQL server. With `graphql-http`, you can just send an HTTP POST request to the endpoint you mounted your GraphQL server on, passing the GraphQL query as the `query` field in a JSON payload.
66

7-
For example, let's say we mounted a GraphQL server on http://localhost:4000/graphql as in the example code for [running an Express GraphQL server](/running-an-express-graphql-server/), and we want to send the GraphQL query `{ hello }`. We can do this from the command line with `curl`. If you paste this into a terminal:
7+
For example, let's say we mounted a GraphQL server on http://localhost:4000/graphql as in the example code for [running an Express GraphQL server](./running-an-express-graphql-server), and we want to send the GraphQL query `{ hello }`. We can do this from the command line with `curl`. If you paste this into a terminal:
88

99
```bash
1010
curl -X POST \
@@ -42,9 +42,9 @@ You should see the data returned, logged in the console:
4242
data returned: Object { hello: "Hello world!" }
4343
```
4444

45-
In this example, the query was just a hardcoded string. As your application becomes more complex, and you add GraphQL endpoints that take arguments as described in [Passing Arguments](/passing-arguments/), you will want to construct GraphQL queries using variables in client code. You can do this by including a keyword prefixed with a dollar sign in the query, and passing an extra `variables` field on the payload.
45+
In this example, the query was just a hardcoded string. As your application becomes more complex, and you add GraphQL endpoints that take arguments as described in [Passing Arguments](./passing-arguments), you will want to construct GraphQL queries using variables in client code. You can do this by including a keyword prefixed with a dollar sign in the query, and passing an extra `variables` field on the payload.
4646

47-
For example, let's say you're running the example server from [Passing Arguments](/passing-arguments/) that has a schema of
47+
For example, let's say you're running the example server from [Passing Arguments](./passing-arguments) that has a schema of
4848

4949
```graphql
5050
type Query {
@@ -82,4 +82,4 @@ Using this syntax for variables is a good idea because it automatically prevents
8282

8383
In general, it will take a bit more time to set up a GraphQL client like Relay, but it's worth it to get more features as your application grows. You might want to start out just using HTTP requests as the underlying transport layer, and switching to a more complex client as your application gets more complex.
8484

85-
At this point you can write a client and server in GraphQL for an API that receives a single string. To do more, you will want to [learn how to use the other basic data types](/basic-types/).
85+
At this point you can write a client and server in GraphQL for an API that receives a single string. To do more, you will want to [learn how to use the other basic data types](./basic-types).

website/pages/index.mdx renamed to website/pages/docs/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ GraphQL.JS is the reference implementation to the [GraphQL Specification](https:
77
while closely following the Specification.
88

99
You can build GraphQL servers, clients, and tools with this library, it's designed so you can choose which parts you use, for example, you can build your own parser
10-
and use the execution/validation from the library. There also a lot of useful utilities for schema-diffing, working with arguments and [many more](./utilities.mdx).
10+
and use the execution/validation from the library. There also a lot of useful utilities for schema-diffing, working with arguments and many more.
1111

1212
In the following chapters you'll find out more about the three critical pieces of this library
1313

1414
- The GraphQL language
1515
- Document validation
1616
- GraphQL Execution
1717

18-
You can also code along on [a tutorial](./getting-started.mdx).
18+
You can also code along on [a tutorial](/docs/getting-started).

website/pages/mutations-and-input-types.mdx renamed to website/pages/docs/mutations-and-input-types.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,4 @@ fetch('/graphql', {
402402
.then((data) => console.log('data returned:', data));
403403
```
404404

405-
One particular type of mutation is operations that change users, like signing up a new user. While you can implement this using GraphQL mutations, you can reuse many existing libraries if you learn about [GraphQL with authentication and Express middleware](/authentication-and-express-middleware/).
405+
One particular type of mutation is operations that change users, like signing up a new user. While you can implement this using GraphQL mutations, you can reuse many existing libraries if you learn about [GraphQL with authentication and Express middleware](./authentication-and-express-middleware).

website/pages/object-types.mdx renamed to website/pages/docs/object-types.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Tabs } from 'nextra/components';
66

77
In many cases, you don't want to return a number or a string from an API. You want to return an object that has its own complex behavior. GraphQL is a perfect fit for this.
88

9-
In GraphQL schema language, the way you define a new object type is the same way we have been defining the `Query` type in our examples. Each object can have fields that return a particular type, and methods that take arguments. For example, in the [Passing Arguments](/passing-arguments/) documentation, we had a method to roll some random dice:
9+
In GraphQL schema language, the way you define a new object type is the same way we have been defining the `Query` type in our examples. Each object can have fields that return a particular type, and methods that take arguments. For example, in the [Passing Arguments](./passing-arguments) documentation, we had a method to roll some random dice:
1010

1111
<Tabs items={['SDL', 'Code']}>
1212
<Tabs.Tab>
@@ -369,4 +369,4 @@ If you run this code with `node server.js` and browse to http://localhost:4000/g
369369

370370
This way of defining object types often provides advantages over a traditional REST API. Instead of doing one API request to get basic information about an object, and then multiple subsequent API requests to find out more information about that object, you can get all of that information in one API request. That saves bandwidth, makes your app run faster, and simplifies your client-side logic.
371371

372-
So far, every API we've looked at is designed for returning data. In order to modify stored data or handle complex input, it helps to [learn about mutations and input types](/mutations-and-input-types/).
372+
So far, every API we've looked at is designed for returning data. In order to modify stored data or handle complex input, it helps to [learn about mutations and input types](./mutations-and-input-types).

website/pages/oneof-input-objects.mdx renamed to website/pages/docs/oneof-input-objects.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const schema = buildSchema(`
2424
shelfNumber: Int!
2525
positionOnShelf: Int!
2626
}
27-
27+
2828
input ProductSpecifier @oneOf {
2929
id: ID
3030
name: String
@@ -88,4 +88,4 @@ const schema = new GraphQLSchema({
8888

8989
It doesn't matter whether you have 2 or more inputs here, all that matters is
9090
that your user will have to specify one, and only one, for this input to be valid.
91-
The values are not limited to scalars, lists and other input object types are also allowed.
91+
The values are not limited to scalars, lists and other input object types are also allowed.

website/pages/passing-arguments.mdx renamed to website/pages/docs/passing-arguments.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Passing Arguments
44

55
import { Tabs } from 'nextra/components';
66

7-
Just like a REST API, it's common to pass arguments to an endpoint in a GraphQL API. By defining the arguments in the schema language, typechecking happens automatically. Each argument must be named and have a type. For example, in the [Basic Types documentation](/basic-types/) we had an endpoint called `rollThreeDice`:
7+
Just like a REST API, it's common to pass arguments to an endpoint in a GraphQL API. By defining the arguments in the schema language, typechecking happens automatically. Each argument must be named and have a type. For example, in the [Basic Types documentation](./basic-types) we had an endpoint called `rollThreeDice`:
88

99
```graphql
1010
type Query {
@@ -221,4 +221,4 @@ fetch('/graphql', {
221221

222222
Using `$dice` and `$sides` as variables in GraphQL means we don't have to worry about escaping on the client side.
223223

224-
With basic types and argument passing, you can implement anything you can implement in a REST API. But GraphQL supports even more powerful queries. You can replace multiple API calls with a single API call if you learn how to [define your own object types](/object-types/).
224+
With basic types and argument passing, you can implement anything you can implement in a REST API. But GraphQL supports even more powerful queries. You can replace multiple API calls with a single API call if you learn how to [define your own object types](./object-types).

website/pages/running-an-express-graphql-server.mdx renamed to website/pages/docs/running-an-express-graphql-server.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ app.get('/', (_req, res) => {
114114
If you navigate to [http://localhost:4000](http://localhost:4000), you should see an interface that lets you enter queries;
115115
now you can use the GraphiQL IDE tool to issue GraphQL queries directly in the browser.
116116

117-
At this point you have learned how to run a GraphQL server. The next step is to learn how to [issue GraphQL queries from client code](/graphql-clients/).
117+
At this point you have learned how to run a GraphQL server. The next step is to learn how to [issue GraphQL queries from client code](./graphql-clients).

website/tailwind.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const config = {
44
content: [
55
'./pages/**/*.{ts,tsx,mdx}',
66
'./icons/**/*.{ts,tsx,mdx}',
7-
'./css/**/*.css',
87
'./theme.config.tsx',
98
],
109
theme: {

website/vercel.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"source": "/api",
55
"destination": "/api-v16/graphql",
66
"permanent": true
7+
},
8+
{
9+
"source": "/",
10+
"destination": "/docs",
11+
"permanent": true
712
}
813
]
914
}

0 commit comments

Comments
 (0)