diff --git a/Documentation/pages/docs/features/graphql-over-http.mdx b/Documentation/pages/docs/features/graphql-over-http.mdx index daed697..a6e2272 100644 --- a/Documentation/pages/docs/features/graphql-over-http.mdx +++ b/Documentation/pages/docs/features/graphql-over-http.mdx @@ -2,6 +2,10 @@ import { Callout } from 'nextra-theme-docs' # GraphQL over HTTP + +Pioneer is a GraphQL over HTTP spec compliant server [implementation](https://github.com/graphql/graphql-http#servers) + + 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 diff --git a/Documentation/pages/docs/index.mdx b/Documentation/pages/docs/index.mdx index 319a065..f549e4d 100644 --- a/Documentation/pages/docs/index.mdx +++ b/Documentation/pages/docs/index.mdx @@ -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) \ No newline at end of file +Pioneer is compliant with the [GraphQL over HTTP spec](https://github.com/graphql/graphql-http#servers) \ No newline at end of file diff --git a/Documentation/pages/docs/web-frameworks/vapor.mdx b/Documentation/pages/docs/web-frameworks/vapor.mdx index 94179e0..bc27d07 100644 --- a/Documentation/pages/docs/web-frameworks/vapor.mdx +++ b/Documentation/pages/docs/web-frameworks/vapor.mdx @@ -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. + ```swift {16-18} showLineNumbers copy import Pioneer import Vapor @@ -58,6 +59,26 @@ app.middleware.use( ) ``` + +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) + } + ) +) +``` + + + #### 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. diff --git a/README.md b/README.md index 1a80c3c..a072212 100644 --- a/README.md +++ b/README.md @@ -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