Skip to content

Commit

Permalink
doc: Spec-compliant + async throws context
Browse files Browse the repository at this point in the history
  • Loading branch information
d-exclaimation committed Dec 28, 2022
1 parent 1c3fb67 commit e549825
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Documentation/pages/docs/features/graphql-over-http.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { Callout } from 'nextra-theme-docs'

# GraphQL over HTTP

<Callout type="info" emoji="🏅">
Pioneer is a GraphQL over HTTP spec compliant server [implementation](https://github.com/graphql/graphql-http#servers)
</Callout>

GraphQL spec define how a GraphQL operation is supposed to be performed through HTTP. The spec specify that operations can be done through either **GET** and **POST** request. Both of these are supported by Pioneer.

## HTTP Strategy
Expand Down
2 changes: 1 addition & 1 deletion Documentation/pages/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Subscriptions using GraphQL over WebSocket protocols such as [graphql-ws](https:
### 🚀 Wide range of features
HTTP resolving strategy, extensive context building, [AsyncEventStream](https://swiftpackageindex.com/d-exclaimation/pioneer/documentation/pioneer/asynceventstream) and [PubSub](https://swiftpackageindex.com/d-exclaimation/pioneer/documentation/pioneer/pubsub)
### 🏅 Spec-compliant
Pioneer is compliant with the [GraphQL over HTTP spec](https://github.com/d-exclaimation/graphql-http/blob/with-pioneer/implementations/pioneer-swift/README.md)
Pioneer is compliant with the [GraphQL over HTTP spec](https://github.com/graphql/graphql-http#servers)
21 changes: 21 additions & 0 deletions Documentation/pages/docs/web-frameworks/vapor.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Pioneer provide a similar solution to `@apollo/server/express4` for building con
This request and response will be request-specific / different for each GraphQL HTTP request.
</Callout>


```swift {16-18} showLineNumbers copy
import Pioneer
import Vapor
Expand All @@ -58,6 +59,26 @@ app.middleware.use(
)
```

<Callout type="info">
Context builder can be asynchronous and/or throwing.

If the context builder throws, it will prevent the operation from being executed

```swift {4-6} showLineNumbers copy
app.middleware.use(
server.vaporMiddleware(
context: { req, _ async throws in
guard let user = await auth(req) else {
throw Abort(.badRequest) // Response status code of 400
}
return Context(req: req)
}
)
)
```

</Callout>

#### Request (HTTP)

The request given is directly from [Vapor](https://github.com/vapor/vapor), so you can use any method you would use in a regular [Vapor](https://github.com/vapor/vapor) application to get any values from it.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fd-exclaimation%2Fpioneer%2Fbadge%3Ftype%3Dplatforms&style=flat-square)](https://swiftpackageindex.com/d-exclaimation/pioneer)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fd-exclaimation%2Fpioneer%2Fbadge%3Fref%3Dmain&style=flat-square)](https://actions-badge.atrox.dev/d-exclaimation/pioneer/goto?ref=main)

Pioneer is an open-source, [spec-compliant](https://github.com/d-exclaimation/graphql-http/blob/with-pioneer/implementations/pioneer-swift/README.md) GraphQL server that's compatible with any GraphQL schema built with [GraphQLSwift/GraphQL](https://github.com/GraphQLSwift/GraphQL).
Pioneer is an open-source, [spec-compliant](https://github.com/graphql/graphql-http#servers) GraphQL server that's compatible with any GraphQL schema built with [GraphQLSwift/GraphQL](https://github.com/GraphQLSwift/GraphQL).

## Setup

Expand Down

0 comments on commit e549825

Please sign in to comment.