Skip to content

Commit 36515d8

Browse files
authored
docs(pylon.md): update to pylon v2 (graphql#1779)
1 parent 747a68c commit 36515d8

File tree

1 file changed

+21
-11
lines changed
  • src/code/language-support/javascript/server

1 file changed

+21
-11
lines changed

src/code/language-support/javascript/server/pylon.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
---
22
name: Pylon
3-
description: A code-first approach to GraphQL API development that generates schemas from TypeScript in real-time, enhancing development speed, type safety, and error reduction, with instant reflection of code changes in the API. For more information, go to https://pylon.cronit.io
3+
description: A code-first framework for GraphQL API development, where your schema reflects your functionality. Run `npm create pylon@latest` to get started.
44
url: https://pylon.cronit.io
55
github: getcronit/pylon
66
---
77

8+
1. **Create**
9+
10+
```bash
11+
npm create pylon@latest
12+
```
13+
14+
2. **Develop**
15+
816
Example service:
917

1018
```typescript
11-
import { defineService } from "@getcronit/pylon"
19+
import { app } from "@getcronit/pylon"
1220

1321
class User {
1422
name: string
@@ -25,24 +33,26 @@ const users = [
2533
new User("Charlie", "[email protected]"),
2634
]
2735

28-
export default defineService({
36+
export const graphql = {
2937
Query: {
3038
users,
3139
user: (name: string) => {
3240
return users.find(user => user.name === name)
3341
},
34-
Mutation: {
35-
addUser: (name: string, email: string) => {
36-
const user = new User(name, email)
37-
users.push(user)
38-
return user
39-
},
42+
},
43+
Mutation: {
44+
addUser: (name: string, email: string) => {
45+
const user = new User(name, email)
46+
users.push(user)
47+
return user
4048
},
4149
},
42-
})
50+
}
51+
52+
export default app
4353
```
4454

45-
After running the service, you can query it using GraphQL:
55+
3. **Query**
4656

4757
```graphql
4858
query User {

0 commit comments

Comments
 (0)