@alxia/create 0.4.0 → 0.4.1

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/docs/roadmap.md CHANGED
@@ -64,6 +64,10 @@ Nothing scheduled yet.
64
64
 
65
65
  ## Shipped
66
66
 
67
+ ### 0.4.1
68
+
69
+ - **`graphqlClient` in the `graphql` template.** Its spec calls the app through `graphqlClient` from `@alxia/graphql/testing`, in place of a helper of its own.
70
+
67
71
  ### 0.4.0
68
72
 
69
73
  - **`TRUSTED_PROXIES` in the `api` and `graphql` templates.** Optional and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alxia/create",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Start an alxia app: `bun create @alxia` writes a minimal API, a spec-first one, a GraphQL one, or React Router's official template served by alxia",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,11 +41,11 @@
41
41
  ]
42
42
  },
43
43
  "devDependencies": {
44
- "@alxia/core": "^0.11.0",
44
+ "@alxia/core": "^0.13.0",
45
45
  "@alxia/env": "^0.2.0",
46
- "@alxia/graphql": "^0.6.3",
47
- "@alxia/openapi": "^0.6.5",
48
- "@alxia/react-router": "^0.7.2",
46
+ "@alxia/graphql": "^0.7.0",
47
+ "@alxia/openapi": "^0.6.7",
48
+ "@alxia/react-router": "^0.7.4",
49
49
  "@graphql-codegen/cli": "7.4.3",
50
50
  "@graphql-codegen/typescript": "6.1.0",
51
51
  "@graphql-codegen/typescript-resolvers": "6.1.0",
@@ -1,35 +1,28 @@
1
1
  import { describe, expect, test } from "bun:test";
2
+ import { graphqlClient } from "@alxia/graphql/testing";
2
3
  import { app } from "./app";
3
4
  import { db, pubsub, queries } from "./store";
4
5
 
5
- interface Result {
6
- data?: Record<string, unknown>;
7
- errors?: { message: string; extensions?: { code?: string } }[];
8
- }
9
-
10
6
  // POST /graphql in process, as a client would: no port.
11
- async function query(
7
+ const client = graphqlClient(app);
8
+ const query = (
12
9
  source: string,
13
10
  options: { token?: string; variables?: Record<string, unknown> } = {},
14
- ): Promise<Result> {
15
- const response = await app.request("/graphql", {
16
- method: "POST",
17
- headers: {
18
- "content-type": "application/json",
19
- ...(options.token && { authorization: `Bearer ${options.token}` }),
20
- },
21
- body: JSON.stringify({ query: source, variables: options.variables }),
11
+ ) =>
12
+ client.query<Record<string, unknown>>(source, {
13
+ ...(options.variables && { variables: options.variables }),
14
+ ...(options.token && {
15
+ headers: { authorization: `Bearer ${options.token}` },
16
+ }),
22
17
  });
23
- return response.json();
24
- }
25
18
 
26
19
  const ADD =
27
20
  "mutation ($text: String!) { addNote(text: $text) { id text author { name } } }";
28
21
 
29
22
  describe("queries", () => {
30
23
  test("answers { __typename }", async () => {
31
- expect(await query("{ __typename }")).toEqual({
32
- data: { __typename: "Query" },
24
+ expect((await query("{ __typename }")).data).toEqual({
25
+ __typename: "Query",
33
26
  });
34
27
  });
35
28