@fougere/adapter-graphql 0.5.0-alpha.1 → 0.7.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.d.ts +3 -26
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +2 -20
- package/dist/app.js.map +1 -1
- package/dist/auto-register.d.ts +8 -18
- package/dist/auto-register.d.ts.map +1 -1
- package/dist/auto-register.js +19 -60
- package/dist/auto-register.js.map +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -9
- package/dist/index.js.map +1 -1
- package/dist/pothos-entry.d.ts +1 -7
- package/dist/pothos-entry.d.ts.map +1 -1
- package/dist/pothos-entry.js +1 -7
- package/dist/pothos-entry.js.map +1 -1
- package/dist/pothos.d.ts +10 -76
- package/dist/pothos.d.ts.map +1 -1
- package/dist/pothos.js +42 -143
- package/dist/pothos.js.map +1 -1
- package/dist/serve.d.ts +2 -19
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +2 -20
- package/dist/serve.js.map +1 -1
- package/package.json +3 -3
- package/src/app.ts +3 -26
- package/src/auto-register.ts +25 -76
- package/src/index.ts +1 -9
- package/src/pothos-entry.ts +1 -7
- package/src/pothos.ts +48 -154
- package/src/serve.ts +3 -26
package/src/serve.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serve a GraphQL schema on an HttpRouter — no Apollo, no Yoga needed.
|
|
3
|
-
*
|
|
4
|
-
* Uses the `graphql` package directly for execution.
|
|
5
|
-
* GraphiQL is available as an explicit opt-in for trusted development environments.
|
|
6
|
-
*/
|
|
1
|
+
/** Serve a GraphQL schema on an HttpRouter — no Apollo, no Yoga needed. */
|
|
7
2
|
import type { HttpRouter, ResponseResult } from '@fougere/http';
|
|
8
3
|
import { getOperationAST, graphql, parse, type GraphQLSchema } from 'graphql';
|
|
9
4
|
|
|
@@ -44,19 +39,7 @@ function graphiqlHtml(path: string): string {
|
|
|
44
39
|
</html>`;
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
/**
|
|
48
|
-
* Register a GraphQL endpoint on an HttpRouter.
|
|
49
|
-
*
|
|
50
|
-
* - POST: execute queries/mutations
|
|
51
|
-
* - GET with `query` param: execute queries
|
|
52
|
-
* - GET from browser (no `query` param): serve GraphiQL only with `playground: true`
|
|
53
|
-
*
|
|
54
|
-
* ```ts
|
|
55
|
-
* import { registerGraphQL } from '@fougere/adapter-graphql'
|
|
56
|
-
*
|
|
57
|
-
* registerGraphQL(router, schema, { playground: process.env.NODE_ENV === 'development' })
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
42
|
+
/** Register a GraphQL endpoint on an HttpRouter. */
|
|
60
43
|
export function registerGraphQL(
|
|
61
44
|
router: HttpRouter,
|
|
62
45
|
schema: GraphQLSchema,
|
|
@@ -65,13 +48,7 @@ export function registerGraphQL(
|
|
|
65
48
|
const path = options?.path ?? '/graphql';
|
|
66
49
|
const playground = options?.playground ?? false;
|
|
67
50
|
|
|
68
|
-
/**
|
|
69
|
-
* The one place this file states what a GraphQL request answers.
|
|
70
|
-
*
|
|
71
|
-
* A GraphQL error is not an HTTP error — the transport succeeded and the errors ride
|
|
72
|
-
* in the body — so every executed request is 200 whatever the resolvers said. The two
|
|
73
|
-
* methods differ in where they READ the request, never in how they answer it.
|
|
74
|
-
*/
|
|
51
|
+
/** The one place this file states what a GraphQL request answers. */
|
|
75
52
|
const answer = async (request: GraphQLRequest): Promise<ResponseResult> => ({
|
|
76
53
|
status: 200,
|
|
77
54
|
data: await graphql({
|