@quilted/create 0.1.81 → 0.1.82

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @quilted/create
2
2
 
3
+ ## 0.1.82
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c40bc1de`](https://github.com/lemonmade/quilt/commit/c40bc1deb3e3b48c30c881a4dd7bd98e2807a596) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix more GraphQL template issues
8
+
3
9
  ## 0.1.81
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quilted/create",
3
3
  "type": "module",
4
- "version": "0.1.81",
4
+ "version": "0.1.82",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,7 +9,9 @@ import startQuery from './StartQuery.graphql';
9
9
  describe('<Start />', () => {
10
10
  it('welcomes the user with their name', async () => {
11
11
  const name = 'Winston';
12
- const graphql = new GraphQLController([fillGraphQL(startQuery, {name})]);
12
+ const graphql = new GraphQLController([
13
+ fillGraphQL(startQuery, {me: {name}}),
14
+ ]);
13
15
 
14
16
  const start = await renderApp(<Start />, {graphql});
15
17
 
@@ -8,7 +8,7 @@ export default function Start() {
8
8
 
9
9
  return (
10
10
  <div className={styles.Start}>
11
- {data ? `Hello ${data.name}!` : 'Hello!'}
11
+ {data ? `Hello ${data.me.name}!` : 'Hello!'}
12
12
  </div>
13
13
  );
14
14
  }
@@ -1,3 +1,5 @@
1
1
  query Start {
2
- name
2
+ me {
3
+ name
4
+ }
3
5
  }
@@ -1,9 +1,13 @@
1
1
  import {graphql} from 'graphql';
2
+ import {
3
+ toGraphQLSource,
4
+ type GraphQLFetch,
5
+ type GraphQLResult,
6
+ } from '@quilted/quilt/graphql';
2
7
  import {
3
8
  createGraphQLSchema,
4
9
  createGraphQLResolverBuilder,
5
10
  } from '@quilted/quilt/graphql/server';
6
- import type {GraphQLResult, GraphQLSource} from '@quilted/quilt/graphql';
7
11
 
8
12
  import schemaSource, {type Schema} from '../graphql/schema.ts';
9
13
 
@@ -26,22 +30,13 @@ const Query = createQueryResolver({
26
30
 
27
31
  const schema = createGraphQLSchema(schemaSource, {Query, Person});
28
32
 
29
- export async function performGraphQLOperation<
30
- Data = Record<string, unknown>,
31
- Variables = Record<string, unknown>,
32
- >(
33
- operation: GraphQLSource<Data, Variables>,
34
- {
35
- variables,
36
- operationName,
37
- }: {variables?: Variables; operationName?: string} = {},
38
- ) {
39
- const result = await graphql({
40
- schema,
41
- source: operation,
42
- operationName,
43
- variableValues: variables,
44
- });
45
-
46
- return result as GraphQLResult<Data>;
47
- }
33
+ export const performGraphQLOperation: GraphQLFetch =
34
+ async function performGraphQLOperation(operation, options) {
35
+ const result = await graphql({
36
+ schema,
37
+ source: toGraphQLSource(operation),
38
+ variableValues: options?.variables as Readonly<{}>,
39
+ });
40
+
41
+ return result as GraphQLResult<any>;
42
+ };
@@ -1,7 +1,6 @@
1
1
  import '@quilted/quilt/globals';
2
2
 
3
3
  import {RequestRouter, JSONResponse} from '@quilted/quilt/request-router';
4
- import {type GraphQLFetch} from '@quilted/quilt/graphql';
5
4
  import {BrowserAssets} from '@quilted/quilt/magic/assets';
6
5
 
7
6
  const router = new RequestRouter();
@@ -29,23 +28,13 @@ router.get(async (request) => {
29
28
  import('@quilted/quilt/server'),
30
29
  ]);
31
30
 
32
- // GraphQL API, called during server rendering
33
- const fetchGraphQL: GraphQLFetch = async (operation, options) => {
34
- const result = await performGraphQLOperation<any>(
35
- (operation as any).source,
36
- {
37
- variables: options?.variables as any,
38
- operationName: (operation as any).name,
39
- },
40
- );
41
-
42
- return result;
43
- };
44
-
45
- const response = await renderToResponse(<App fetchGraphQL={fetchGraphQL} />, {
46
- request,
47
- assets,
48
- });
31
+ const response = await renderToResponse(
32
+ <App fetchGraphQL={performGraphQLOperation} />,
33
+ {
34
+ request,
35
+ assets,
36
+ },
37
+ );
49
38
 
50
39
  return response;
51
40
  });