Skip to content

docs: add Pylon service #1735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions src/code/language-support/javascript /server/pylon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
name: Pylon
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
url: https://pylon.cronit.io
github: getcronit/pylon
---

Example service:

```typescript
import { defineService } from "@getcronit/pylon"

class User {
name: string
email: string
constructor(name: string, email: string) {
this.name = name
this.email = email
}
}

const users = [
new User("Alice", "alice@example.com"),
new User("Bob", "bob@example.com"),
new User("Charlie", "charlie@example.com"),
]

export default defineService({
Query: {
users,
user: (name: string) => {
return users.find(user => user.name === name)
},
Mutation: {
addUser: (name: string, email: string) => {
const user = new User(name, email)
users.push(user)
return user
},
},
},
})
```

After running the service, you can query it using GraphQL:

```graphql
query User {
user(name: "Alice") {
name
email
}
}

query Users {
users {
name
email
}
}

mutation AddUser {
addUser(name: "Corina", email: "corina@example.com") {
name
email
}
}
```