Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "root",
"private": true,
"scripts": {
"postinstall": "node ./scripts/fix-apollo.js && ./scripts/copy-yarn-lock.sh",
"postinstall": "./scripts/copy-yarn-lock.sh",
"prebuild": "yarn run clean:build",
"build": "turbo run build build:types",
"//build:pkg": "# Builds only packages, useful when running starters in dev mode",
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/typings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VulcanModel } from "@vulcanjs/model";
import { OperationVariables } from "@apollo/client";
import type { OperationVariables } from "@apollo/client/core/index.js";
import { VulcanFieldSchema, VulcanSchema } from "@vulcanjs/schema";
import type { FilterableInput /*, VulcanCrudModel*/ } from "@vulcanjs/crud";

Expand Down
2 changes: 1 addition & 1 deletion packages/meteor-legacy/hooks/currentUser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useQuery } from "@apollo/client";
import { useQuery } from "@apollo/client/react/index.js";
import gql from "graphql-tag";
import get from "lodash/get.js";

Expand Down
16 changes: 10 additions & 6 deletions packages/meteor-legacy/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import {
MutationTuple,
MutationHookOptions,
MutationFunctionOptions,
OperationVariables,
} from "@apollo/client";
} from "@apollo/client/react/index.js";
import type { OperationVariables } from "@apollo/client/core/index.js";
import gql from "graphql-tag";

import { ApolloVariables } from "@vulcanjs/graphql";

// We modify the result function so that variables can be provided as first param,
// which is more intuitive
// Normal mutation function type (sadly not exported directly by Apollo)
type MutationFunction<TData = any, TVariables = OperationVariables> =
MutationTuple<TData, TVariables>["0"];
type MutationResult<TData = any, TVariables = OperationVariables> =
MutationTuple<TData, TVariables>["1"];
type MutationFunction<
TData = any,
TVariables = OperationVariables
> = MutationTuple<TData, TVariables>["0"];
type MutationResult<
TData = any,
TVariables = OperationVariables
> = MutationTuple<TData, TVariables>["1"];

type MutationFunctionResult<TData, TVariables> = ReturnType<
MutationFunction<TData, TVariables>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-hooks/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

// */

import { useMutation, MutationResult, FetchResult } from "@apollo/client";
import { useMutation, MutationResult } from "@apollo/client/react/index.js";
import type { FetchResult } from "@apollo/client/core/index.js";
import gql from "graphql-tag";

import { filterFunction } from "@vulcanjs/mongo/client";
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hooks/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

*/

import { useMutation, MutationResult } from "@apollo/client";
import { useMutation, MutationResult } from "@apollo/client/react/index.js";
import gql from "graphql-tag";
import {
deleteClientTemplate,
Expand Down
6 changes: 5 additions & 1 deletion packages/react-hooks/multi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ Differences with Vulcan Meteor:
*/

import { DocumentNode } from "graphql";
import { useQuery, QueryResult, QueryHookOptions } from "@apollo/client";
import {
useQuery,
QueryResult,
QueryHookOptions,
} from "@apollo/client/react/index.js";
import { useState } from "react";
import {
VulcanGraphqlModel,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-hooks/single.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {

import { computeQueryVariables } from "./variables";
import {
OperationVariables,
useQuery,
QueryResult,
QueryHookOptions,
} from "@apollo/client";
} from "@apollo/client/react/index.js";
import type { OperationVariables } from "@apollo/client/core/index.js";
import gql from "graphql-tag";

const defaultInput = {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hooks/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MutationHookOptions } from "@apollo/client";
import type { MutationHookOptions } from "@apollo/client/react/index.js";
import { Fragment, VulcanGraphqlModel } from "@vulcanjs/graphql";

export interface VulcanMutationHookOptions<
Expand Down
3 changes: 2 additions & 1 deletion packages/react-hooks/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

// */

import { useMutation, MutationResult, FetchResult } from "@apollo/client";
import { useMutation, MutationResult } from "@apollo/client/react/index.js";
import { FetchResult } from "@apollo/client/core/index.js";
import gql from "graphql-tag";

import {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-hooks/upsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

*/

import { useMutation, MutationResult, FetchResult } from "@apollo/client";
import { useMutation, MutationResult } from "@apollo/client/react/index.js";
import type { FetchResult } from "@apollo/client/core/index.js";
import gql from "graphql-tag";

import { upsertClientTemplate } from "@vulcanjs/graphql";
Expand Down
4 changes: 1 addition & 3 deletions starters/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"private": true,
"scripts": {
"//----- DEVELOP -----": "",
"//_____Lifecycle_____": "",
"postinstall": "node ./.vn/scripts/fix-apollo.js",
"//____Utilities_____": "",
"clean": "rm -Rf ./dist ./storybook-static .yalc .next",
"clean:next": "rm -Rf .next",
Expand All @@ -24,7 +22,7 @@
"dev": "next",
"//_____Build next app_____": "",
"//prebuild": "# Temporary fix for https://github.com/vercel/next.js/issues/35110 and https://github.com/yarnpkg/berry/issues/1339#issuecomment-1136132035",
"prebuild": "(.vn/scripts/is-monorepo.js && rm -Rf ./node_modules/@vulcanjs && mkdir -p ./node_modules/@vulcanjs && cp -R ../../packages/* ./node_modules/@vulcanjs) || echo 'Not in the context of a monorepo, ok'",
"prebuild": "(node .vn/scripts/is-monorepo.js && echo 'in the context of a Monorepo, will clone local packages' && rm -Rf ./node_modules/@vulcanjs && mkdir -p ./node_modules/@vulcanjs && cp -R ../../packages/* ./node_modules/@vulcanjs) || echo 'Not in the context of a monorepo, ok'",
"//build": "# Tip: on failure, we drop .next to avoid caching issue. Run 'prebuild' explicitely",
"build": "yarn run prebuild && next build || (rm -Rf .next && exit 1) && yarn run postbuild",
"postbuild": "next-sitemap --config vulcan-next-sitemap.js",
Expand Down
8 changes: 4 additions & 4 deletions starters/next/packages/@vulcanjs/next-apollo/apolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ export function initializeApollo(
}

export function useApollo(initialState, options: CreateApolloClientOptions) {
const store = useMemo(() => initializeApollo(initialState, options), [
initialState,
options,
]);
const store = useMemo(
() => initializeApollo(initialState, options),
[initialState, options]
);
return store;
}