@quilted/create 0.1.65 → 0.1.66

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.66
4
+
5
+ ### Patch Changes
6
+
7
+ - [#571](https://github.com/lemonmade/quilt/pull/571) [`3bdd0dd3`](https://github.com/lemonmade/quilt/commit/3bdd0dd39654e64e52465c46aea95c7c06f2e1cb) Thanks [@lemonmade](https://github.com/lemonmade)! - Clean up GraphQL library for a V1
8
+
3
9
  ## 0.1.65
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var prompts = require('../../../../../../_virtual/prompts2.cjs');
3
+ var prompts = require('../../../../../../_virtual/prompts.cjs');
4
4
  var index = require('./elements/index.cjs');
5
5
 
6
6
  var hasRequiredPrompts;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var prompts = require('../../../../../../_virtual/prompts.cjs');
3
+ var prompts = require('../../../../../../_virtual/prompts2.cjs');
4
4
  var index = require('./elements/index.cjs');
5
5
 
6
6
  var hasRequiredPrompts;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quilted/create",
3
3
  "type": "module",
4
- "version": "0.1.65",
4
+ "version": "0.1.66",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,13 +1,17 @@
1
1
  import {useMemo} from 'react';
2
+
2
3
  import {
3
4
  QuiltApp,
4
- GraphQLContext,
5
- createGraphQLHttpFetch,
6
- type GraphQLFetch,
7
5
  useRoutes,
8
6
  RoutePreloading,
9
7
  type PropsWithChildren,
10
8
  } from '@quilted/quilt';
9
+ import {
10
+ GraphQLContext,
11
+ createGraphQLHttpFetch,
12
+ type GraphQLFetch,
13
+ } from '@quilted/quilt/graphql';
14
+
11
15
  import {ReactQueryContext} from '@quilted/react-query';
12
16
  import {QueryClient} from '@tanstack/react-query';
13
17
 
@@ -55,7 +59,7 @@ function AppContext({
55
59
  const {fetchGraphQL, queryClient} = useMemo(() => {
56
60
  return {
57
61
  fetchGraphQL:
58
- customFetchGraphQL ?? createGraphQLHttpFetch({uri: '/api/graphql'}),
62
+ customFetchGraphQL ?? createGraphQLHttpFetch({url: '/api/graphql'}),
59
63
  queryClient: new QueryClient(),
60
64
  };
61
65
  }, [customFetchGraphQL]);
@@ -1,21 +1,38 @@
1
- import {type GraphQLResult} from '@quilted/quilt';
2
- import {type GraphQLSchema} from 'graphql';
1
+ import {graphql} from 'graphql';
2
+ import {
3
+ createGraphQLSchema,
4
+ createGraphQLResolverBuilder,
5
+ } from '@quilted/quilt/graphql/server';
6
+ import type {GraphQLResult, GraphQLSource} from '@quilted/quilt/graphql';
3
7
 
4
- export async function performGraphQLOperation<Data = Record<string, unknown>>(
5
- operation: string,
8
+ import schemaSource, {type Schema} from '../graphql/schema.ts';
9
+
10
+ const {createResolver, createQueryResolver} =
11
+ createGraphQLResolverBuilder<Schema>();
12
+
13
+ const Person = createResolver('Person', {
14
+ name: 'Winston',
15
+ });
16
+
17
+ const Query = createQueryResolver({
18
+ me: () => ({}),
19
+ });
20
+
21
+ const schema = createGraphQLSchema(schemaSource, {Query, Person});
22
+
23
+ export async function performGraphQLOperation<
24
+ Data = Record<string, unknown>,
25
+ Variables = Record<string, unknown>,
26
+ >(
27
+ operation: GraphQLSource<Data, Variables>,
6
28
  {
7
29
  variables,
8
30
  operationName,
9
- }: {variables?: Record<string, unknown>; operationName?: string} = {},
31
+ }: {variables?: Variables; operationName?: string} = {},
10
32
  ) {
11
- const [schema, {execute, parse}] = await Promise.all([
12
- getSchema(),
13
- import('graphql'),
14
- ]);
15
-
16
- const result = await execute({
33
+ const result = await graphql({
17
34
  schema,
18
- document: parse(operation),
35
+ source: operation,
19
36
  operationName,
20
37
  variableValues: variables,
21
38
  rootValue: {name: () => 'Winston'},
@@ -23,20 +40,3 @@ export async function performGraphQLOperation<Data = Record<string, unknown>>(
23
40
 
24
41
  return result as GraphQLResult<Data>;
25
42
  }
26
-
27
- let schemaPromise: Promise<GraphQLSchema>;
28
-
29
- function getSchema() {
30
- if (!schemaPromise) {
31
- schemaPromise = (async () => {
32
- const [{buildSchema}, {default: schemaSource}] = await Promise.all([
33
- import('graphql'),
34
- import('../graphql/schema.ts'),
35
- ]);
36
-
37
- return buildSchema(schemaSource);
38
- })();
39
- }
40
-
41
- return schemaPromise;
42
- }
@@ -1,17 +1,16 @@
1
1
  import '@quilted/quilt/global';
2
2
 
3
- import {type GraphQLFetch, type GraphQLData} from '@quilted/quilt';
4
3
  import {createRequestRouter, json} from '@quilted/quilt/request-router';
5
4
  import {createServerRender} from '@quilted/quilt/server';
5
+ import {type GraphQLFetch} from '@quilted/quilt/graphql';
6
6
  import {createBrowserAssets} from '@quilted/quilt/magic/assets';
7
7
 
8
- import {performGraphQLOperation} from './server/graphql.ts';
9
-
10
8
  const router = createRequestRouter();
11
9
 
12
10
  // GraphQL API, called from the client
13
11
  router.post('/api/graphql', async (request) => {
14
- const {query, operationName, variables} = await request.json();
12
+ const [{performGraphQLOperation}, {query, operationName, variables}] =
13
+ await Promise.all([import('./server/graphql.ts'), request.json()]);
15
14
 
16
15
  const result = await performGraphQLOperation(query, {
17
16
  variables,
@@ -25,13 +24,14 @@ router.post('/api/graphql', async (request) => {
25
24
  router.get(
26
25
  createServerRender(
27
26
  async () => {
28
- const {default: App} = await import('./App.tsx');
27
+ const [{default: App}, {performGraphQLOperation}] = await Promise.all([
28
+ import('./App.tsx'),
29
+ import('./server/graphql.ts'),
30
+ ]);
29
31
 
30
32
  // GraphQL API, called during server rendering
31
33
  const fetchGraphQL: GraphQLFetch = async (operation, variables) => {
32
- type Data = GraphQLData<typeof operation>;
33
-
34
- const result = await performGraphQLOperation<Data>(operation.source, {
34
+ const result = await performGraphQLOperation(operation.source, {
35
35
  variables,
36
36
  operationName: operation.name,
37
37
  });
@@ -1,13 +1,14 @@
1
- import {buildSchema} from 'graphql';
2
1
  import {
3
2
  TestGraphQL,
3
+ createGraphQLSchema,
4
4
  createGraphQLFiller,
5
5
  createGraphQLController,
6
6
  type GraphQLController,
7
7
  } from '@quilted/quilt/graphql/testing';
8
8
 
9
- import schema from '../graphql/schema.ts';
9
+ import schemaSource from '../graphql/schema.ts';
10
10
 
11
- export const fillGraphQL = createGraphQLFiller(buildSchema(schema));
11
+ export const schema = createGraphQLSchema(schemaSource);
12
+ export const fillGraphQL = createGraphQLFiller(schema);
12
13
 
13
14
  export {createGraphQLController, TestGraphQL, type GraphQLController};