naystack 1.2.13 → 1.2.14
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.
|
@@ -21,10 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var server_exports = {};
|
|
22
22
|
__export(server_exports, {
|
|
23
23
|
Injector: () => Injector,
|
|
24
|
-
|
|
24
|
+
PreloadQuery: () => PreloadQuery,
|
|
25
|
+
getClient: () => getClient,
|
|
26
|
+
getGraphQLQuery: () => getGraphQLQuery,
|
|
27
|
+
query: () => query
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(server_exports);
|
|
27
30
|
var import_client = require("@apollo/client");
|
|
31
|
+
var import_client_integration_nextjs = require("@apollo/client-integration-nextjs");
|
|
28
32
|
var import_headers = require("next/headers");
|
|
29
33
|
var import_react = require("react");
|
|
30
34
|
function Injector({
|
|
@@ -42,15 +46,31 @@ async function InjectorSuspensed({
|
|
|
42
46
|
const data = await fetch();
|
|
43
47
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
44
48
|
}
|
|
45
|
-
var
|
|
46
|
-
|
|
49
|
+
var { getClient, query, PreloadQuery } = (0, import_client_integration_nextjs.registerApolloClient)(() => {
|
|
50
|
+
return new import_client.ApolloClient({
|
|
47
51
|
cache: new import_client.InMemoryCache(),
|
|
48
52
|
link: new import_client.HttpLink({
|
|
49
|
-
|
|
53
|
+
// this needs to be an absolute url, as relative urls cannot be used in SSR
|
|
54
|
+
uri: "http://example.com/api/graphql",
|
|
55
|
+
fetchOptions: {
|
|
56
|
+
// you can pass additional options that should be passed to `fetch` here,
|
|
57
|
+
// e.g. Next.js-related `fetch` options regarding caching and revalidation
|
|
58
|
+
// see https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options
|
|
59
|
+
}
|
|
50
60
|
})
|
|
51
61
|
});
|
|
62
|
+
});
|
|
63
|
+
var getGraphQLQuery = ({ uri }) => {
|
|
64
|
+
const { query: query2 } = (0, import_client_integration_nextjs.registerApolloClient)(() => {
|
|
65
|
+
return new import_client.ApolloClient({
|
|
66
|
+
cache: new import_client.InMemoryCache(),
|
|
67
|
+
link: new import_client.HttpLink({
|
|
68
|
+
uri
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
});
|
|
52
72
|
return async (_query, options) => {
|
|
53
|
-
const res = await
|
|
73
|
+
const res = await query2({
|
|
54
74
|
query: _query,
|
|
55
75
|
variables: options?.variables,
|
|
56
76
|
context: {
|
|
@@ -72,5 +92,8 @@ var getGraphQLQuery = ({ uri }) => {
|
|
|
72
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
93
|
0 && (module.exports = {
|
|
74
94
|
Injector,
|
|
75
|
-
|
|
95
|
+
PreloadQuery,
|
|
96
|
+
getClient,
|
|
97
|
+
getGraphQLQuery,
|
|
98
|
+
query
|
|
76
99
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as _apollo_client_integration_nextjs from '@apollo/client-integration-nextjs';
|
|
2
|
+
import * as _apollo_client from '@apollo/client';
|
|
3
|
+
import { ApolloClient, OperationVariables } from '@apollo/client';
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import { FC } from 'react';
|
|
3
|
-
import { OperationVariables } from '@apollo/client';
|
|
4
6
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
5
7
|
|
|
6
8
|
type OmittedProps<Y> = Omit<Omit<Y, "loading">, "data">;
|
|
@@ -16,6 +18,9 @@ declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
|
16
18
|
loading: boolean;
|
|
17
19
|
} & Y>;
|
|
18
20
|
} & ComponentProps<Y>): React.JSX.Element;
|
|
21
|
+
declare const getClient: () => ApolloClient<_apollo_client.NormalizedCacheObject>;
|
|
22
|
+
declare const query: <T = any, TVariables extends OperationVariables = OperationVariables>(options: _apollo_client.QueryOptions<TVariables, T>) => Promise<_apollo_client.ApolloQueryResult<_apollo_client.MaybeMasked<T>>>;
|
|
23
|
+
declare const PreloadQuery: _apollo_client_integration_nextjs.PreloadQueryComponent;
|
|
19
24
|
declare const getGraphQLQuery: ({ uri }: {
|
|
20
25
|
uri: string;
|
|
21
26
|
}) => <T, V extends OperationVariables>(_query: TypedDocumentNode<T, V>, options?: {
|
|
@@ -25,4 +30,4 @@ declare const getGraphQLQuery: ({ uri }: {
|
|
|
25
30
|
noCookie?: boolean;
|
|
26
31
|
}) => Promise<T>;
|
|
27
32
|
|
|
28
|
-
export { Injector, getGraphQLQuery };
|
|
33
|
+
export { Injector, PreloadQuery, getClient, getGraphQLQuery, query };
|
package/dist/graphql/server.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as _apollo_client_integration_nextjs from '@apollo/client-integration-nextjs';
|
|
2
|
+
import * as _apollo_client from '@apollo/client';
|
|
3
|
+
import { ApolloClient, OperationVariables } from '@apollo/client';
|
|
1
4
|
import * as React from 'react';
|
|
2
5
|
import { FC } from 'react';
|
|
3
|
-
import { OperationVariables } from '@apollo/client';
|
|
4
6
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
5
7
|
|
|
6
8
|
type OmittedProps<Y> = Omit<Omit<Y, "loading">, "data">;
|
|
@@ -16,6 +18,9 @@ declare function Injector<T, Y>({ fetch, Component, props, }: {
|
|
|
16
18
|
loading: boolean;
|
|
17
19
|
} & Y>;
|
|
18
20
|
} & ComponentProps<Y>): React.JSX.Element;
|
|
21
|
+
declare const getClient: () => ApolloClient<_apollo_client.NormalizedCacheObject>;
|
|
22
|
+
declare const query: <T = any, TVariables extends OperationVariables = OperationVariables>(options: _apollo_client.QueryOptions<TVariables, T>) => Promise<_apollo_client.ApolloQueryResult<_apollo_client.MaybeMasked<T>>>;
|
|
23
|
+
declare const PreloadQuery: _apollo_client_integration_nextjs.PreloadQueryComponent;
|
|
19
24
|
declare const getGraphQLQuery: ({ uri }: {
|
|
20
25
|
uri: string;
|
|
21
26
|
}) => <T, V extends OperationVariables>(_query: TypedDocumentNode<T, V>, options?: {
|
|
@@ -25,4 +30,4 @@ declare const getGraphQLQuery: ({ uri }: {
|
|
|
25
30
|
noCookie?: boolean;
|
|
26
31
|
}) => Promise<T>;
|
|
27
32
|
|
|
28
|
-
export { Injector, getGraphQLQuery };
|
|
33
|
+
export { Injector, PreloadQuery, getClient, getGraphQLQuery, query };
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
HttpLink,
|
|
5
5
|
InMemoryCache
|
|
6
6
|
} from "@apollo/client";
|
|
7
|
+
import { registerApolloClient } from "@apollo/client-integration-nextjs";
|
|
7
8
|
import { cookies } from "next/headers";
|
|
8
9
|
import { Suspense } from "react";
|
|
9
10
|
function Injector({
|
|
@@ -21,15 +22,31 @@ async function InjectorSuspensed({
|
|
|
21
22
|
const data = await fetch();
|
|
22
23
|
return /* @__PURE__ */ React.createElement(Component, { loading: false, ...props || {}, data });
|
|
23
24
|
}
|
|
24
|
-
var
|
|
25
|
-
|
|
25
|
+
var { getClient, query, PreloadQuery } = registerApolloClient(() => {
|
|
26
|
+
return new ApolloClient({
|
|
26
27
|
cache: new InMemoryCache(),
|
|
27
28
|
link: new HttpLink({
|
|
28
|
-
|
|
29
|
+
// this needs to be an absolute url, as relative urls cannot be used in SSR
|
|
30
|
+
uri: "http://example.com/api/graphql",
|
|
31
|
+
fetchOptions: {
|
|
32
|
+
// you can pass additional options that should be passed to `fetch` here,
|
|
33
|
+
// e.g. Next.js-related `fetch` options regarding caching and revalidation
|
|
34
|
+
// see https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options
|
|
35
|
+
}
|
|
29
36
|
})
|
|
30
37
|
});
|
|
38
|
+
});
|
|
39
|
+
var getGraphQLQuery = ({ uri }) => {
|
|
40
|
+
const { query: query2 } = registerApolloClient(() => {
|
|
41
|
+
return new ApolloClient({
|
|
42
|
+
cache: new InMemoryCache(),
|
|
43
|
+
link: new HttpLink({
|
|
44
|
+
uri
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
});
|
|
31
48
|
return async (_query, options) => {
|
|
32
|
-
const res = await
|
|
49
|
+
const res = await query2({
|
|
33
50
|
query: _query,
|
|
34
51
|
variables: options?.variables,
|
|
35
52
|
context: {
|
|
@@ -50,5 +67,8 @@ var getGraphQLQuery = ({ uri }) => {
|
|
|
50
67
|
};
|
|
51
68
|
export {
|
|
52
69
|
Injector,
|
|
53
|
-
|
|
70
|
+
PreloadQuery,
|
|
71
|
+
getClient,
|
|
72
|
+
getGraphQLQuery,
|
|
73
|
+
query
|
|
54
74
|
};
|