|
| 1 | +## Contributing to the Code Page |
| 2 | + |
| 3 | +Hi, thanks for reading the docs! |
| 4 | + |
| 5 | +Secondly, we want to provide a really strong overview of all the libraries in the GraphQL eco-system. To make this |
| 6 | +easy for contributors the code page is automatically generated from a series of markdown files in this repo. |
| 7 | + |
| 8 | +```sh |
| 9 | +$ tree src/content/code |
| 10 | +src/content/code |
| 11 | +├── language-support |
| 12 | +│ ├── c-c |
| 13 | +│ │ └── tools |
| 14 | +│ │ └── libgraphqlparser.md |
| 15 | +│ ├── clojure |
| 16 | +│ │ ├── client |
| 17 | +│ │ │ └── regraph.md |
| 18 | +│ │ └── server |
| 19 | +│ │ ├── alumbra.md |
| 20 | +│ │ ├── graphql-clj.md |
| 21 | +│ │ └── lacinia.md |
| 22 | +│ ├── c-net |
| 23 | +│ │ ├── client |
| 24 | +│ │ │ ├── graphql-client.md |
| 25 | +│ │ │ ├── graphql-net-client.md |
| 26 | +│ │ │ └── sahb-graphqlclient.md |
| 27 | +// etc |
| 28 | +``` |
| 29 | + |
| 30 | +We'd love any new project to include a few paragraphs describing its goals and usage, the goal here is to make it easy for people to decide between options. |
| 31 | + |
| 32 | +Here's an optimal example example of what we're looking for: |
| 33 | + |
| 34 | +- It uses yml frontmatter to provide additional information like repo, npm |
| 35 | +- It explains itself in the 'description' then fills fleshes out that description with some code samples |
| 36 | + |
| 37 | +````md |
| 38 | +--- |
| 39 | +name: Express GraphQL |
| 40 | +description: The reference implementation of a GraphQL API server over an Express webserver. You can use this to run GraphQL in conjunction with a regular Express webserver, or as a standalone GraphQL server. |
| 41 | +url: /graphql-js/running-an-express-graphql-server/ |
| 42 | +github: graphql/express-graphql |
| 43 | +npm: "express-graphql" |
| 44 | +--- |
| 45 | + |
| 46 | +To run an `express-graphql` hello world server: |
| 47 | + |
| 48 | +```bash |
| 49 | +npm install express express-graphql graphql |
| 50 | +``` |
| 51 | + |
| 52 | +Then run `node server.js` with this code in `server.js`: |
| 53 | + |
| 54 | +```js |
| 55 | +var express = require('express'); |
| 56 | +var { graphqlHTTP } = require('express-graphql'); |
| 57 | +var { buildSchema } = require('graphql'); |
| 58 | + |
| 59 | +var schema = buildSchema(` |
| 60 | + type Query { |
| 61 | + hello: String |
| 62 | + } |
| 63 | +`); |
| 64 | + |
| 65 | +var root = { hello: () => 'Hello world!' }; |
| 66 | + |
| 67 | +var app = express(); |
| 68 | +app.use('/graphql', graphqlHTTP({ |
| 69 | + schema: schema, |
| 70 | + rootValue: root, |
| 71 | + graphiql: true, |
| 72 | +})); |
| 73 | +app.listen(4000, () => console.log('Now browse to localhost:4000/graphql')); |
| 74 | +``` |
| 75 | + |
| 76 | +```` |
| 77 | + |
| 78 | +Any library/tool/service has a maximum height in the site, and then it can be expanded by clicking, so if you need quite a lot of space to explain your project then that's OK. |
0 commit comments