@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/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({