Skip to content

Commit 13b6238

Browse files
authored
docs: add Pylon service (graphql#1735)
* docs: add Pylon service * rename src/code/services/pylon.md to src/code/language-support/javascript /server/pylon.md * docs: fix pylon.md format
1 parent 0ed3f20 commit 13b6238

File tree

1 file changed

+68
-0
lines changed
  • src/code/language-support/javascript /server

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
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
4+
url: https://pylon.cronit.io
5+
github: getcronit/pylon
6+
---
7+
8+
Example service:
9+
10+
```typescript
11+
import { defineService } from "@getcronit/pylon"
12+
13+
class User {
14+
name: string
15+
email: string
16+
constructor(name: string, email: string) {
17+
this.name = name
18+
this.email = email
19+
}
20+
}
21+
22+
const users = [
23+
new User("Alice", "[email protected]"),
24+
new User("Bob", "[email protected]"),
25+
new User("Charlie", "[email protected]"),
26+
]
27+
28+
export default defineService({
29+
Query: {
30+
users,
31+
user: (name: string) => {
32+
return users.find(user => user.name === name)
33+
},
34+
Mutation: {
35+
addUser: (name: string, email: string) => {
36+
const user = new User(name, email)
37+
users.push(user)
38+
return user
39+
},
40+
},
41+
},
42+
})
43+
```
44+
45+
After running the service, you can query it using GraphQL:
46+
47+
```graphql
48+
query User {
49+
user(name: "Alice") {
50+
name
51+
email
52+
}
53+
}
54+
55+
query Users {
56+
users {
57+
name
58+
email
59+
}
60+
}
61+
62+
mutation AddUser {
63+
addUser(name: "Corina", email: "[email protected]") {
64+
name
65+
email
66+
}
67+
}
68+
```

0 commit comments

Comments
 (0)