Skip to content

Commit

Permalink
move gql to graphql-tag import instead of faulty @apollo/client
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-burel committed Mar 12, 2022
1 parent 25c4c62 commit f8f44f4
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 21 deletions.
5 changes: 4 additions & 1 deletion packages/meteor-legacy/hooks/currentUser.ts
@@ -1,4 +1,7 @@
import { useQuery, gql } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { useQuery } from "@apollo/client";
import { gql } from "graphql-tag";
import get from "lodash/get.js";

import { currentUserFragment } from "../models/user";
Expand Down
16 changes: 11 additions & 5 deletions packages/meteor-legacy/hooks/hooks.ts
Expand Up @@ -5,18 +5,24 @@ import {
MutationHookOptions,
MutationFunctionOptions,
OperationVariables,
gql,
} from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
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
5 changes: 4 additions & 1 deletion packages/react-hooks/create.ts
Expand Up @@ -26,7 +26,10 @@

// */

import { useMutation, MutationResult, gql, FetchResult } from "@apollo/client";
import { useMutation, MutationResult, FetchResult } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

import { filterFunction } from "@vulcanjs/mongo/client";
import {
Expand Down
6 changes: 5 additions & 1 deletion packages/react-hooks/delete.ts
Expand Up @@ -26,7 +26,11 @@
*/

import { useMutation, MutationResult, gql } from "@apollo/client";
import { useMutation, MutationResult } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

import {
deleteClientTemplate,
Fragment,
Expand Down
6 changes: 5 additions & 1 deletion packages/react-hooks/multi.ts
Expand Up @@ -11,7 +11,11 @@ Differences with Vulcan Meteor:
*/

import { DocumentNode } from "graphql";
import { useQuery, gql, QueryResult, QueryHookOptions } from "@apollo/client";
import { useQuery, QueryResult, QueryHookOptions } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

import { useState } from "react";
import {
multiClientTemplate,
Expand Down
4 changes: 3 additions & 1 deletion packages/react-hooks/single.ts
Expand Up @@ -16,10 +16,12 @@ import { computeQueryVariables } from "./variables";
import {
OperationVariables,
useQuery,
gql,
QueryResult,
QueryHookOptions,
} from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

const defaultInput = {
enableCache: false,
Expand Down
5 changes: 4 additions & 1 deletion packages/react-hooks/update.ts
Expand Up @@ -27,7 +27,10 @@

// */

import { useMutation, MutationResult, gql, FetchResult } from "@apollo/client";
import { useMutation, MutationResult, FetchResult } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

import {
Fragment,
Expand Down
5 changes: 4 additions & 1 deletion packages/react-hooks/upsert.ts
Expand Up @@ -27,7 +27,10 @@
*/

import { useMutation, MutationResult, gql, FetchResult } from "@apollo/client";
import { useMutation, MutationResult, FetchResult } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

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

Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/components/Datatable/DatatableFilter.tsx
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { DocumentNode, gql } from "@apollo/client";
import { DocumentNode } from "@apollo/client";
import { useQuery } from "@apollo/client";
import moment from "moment";
import isEmpty from "lodash/isEmpty.js";
Expand Down
5 changes: 4 additions & 1 deletion packages/react-ui/components/MutationButton.tsx
Expand Up @@ -18,7 +18,10 @@ Example Usage
*/
import React, { useState } from "react";
import { DocumentNode } from "graphql";
import { gql, MutationHookOptions, useMutation } from "@apollo/client";
import { MutationHookOptions, useMutation } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";
import { useVulcanComponents } from "./VulcanComponents/Consumer";
import { LoadingButtonProps } from "./LoadingButton";
// import withMutation from '../containers/registeredMutation';
Expand Down
5 changes: 4 additions & 1 deletion packages/react-ui/components/form/FormComponentLoader.tsx
Expand Up @@ -6,7 +6,10 @@ import React, { useEffect } from "react";
// @see packages/vulcan-lib/lib/modules/fragments.js in Vulcan
// should we reenable this?
// import { expandQueryFragments } from "meteor/vulcan:core";
import { useLazyQuery, gql } from "@apollo/client";
import { useLazyQuery } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";
import isEmpty from "lodash/isEmpty.js";
import { useVulcanComponents } from "../VulcanComponents/Consumer";

Expand Down
5 changes: 4 additions & 1 deletion packages/react-ui/components/form/FormContainer.tsx
Expand Up @@ -42,7 +42,10 @@ import React, { useRef } from "react";
// Utils,
// getFragment,
//"meteor/vulcan:core";
import { DocumentNode, gql } from "@apollo/client";
import { DocumentNode } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

import getFormFragments from "./modules/formFragments";
// import { VulcanModel } from "@vulcanjs/model";
Expand Down
4 changes: 3 additions & 1 deletion packages/react-ui/components/form/modules/formFragments.ts
Expand Up @@ -5,7 +5,9 @@
*/
import _uniq from "lodash/uniq.js";
import _intersection from "lodash/intersection.js";
import { gql } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";
import {
getCreateableFields,
getUpdateableFields,
Expand Down
Expand Up @@ -26,7 +26,9 @@ import {
import { OneFieldGraphql, OneFieldType } from "./fixtures/graphqlModels";

import { getMswServer } from "@vulcanjs/utils/testing";
import { gql } from "@apollo/client";
// @see https://stackoverflow.com/questions/70615613/apollo-client-named-export-remove-not-found
// get gql from graphql-tag directly works with ESM
import { gql } from "graphql-tag";

beforeEach(() => {
// add relevant mocks
Expand Down
@@ -1,7 +1,7 @@
import React from "react";
import { Story, Meta } from "@storybook/react";
import { MutationButton, MutationButtonProps } from "../MutationButton";
import { gql } from "@apollo/client";
import { gql } from "graphql-tag";
import { VulcanComponentsProvider } from "../VulcanComponents";
export default {
component: MutationButton,
Expand Down
7 changes: 5 additions & 2 deletions packages/utils/tsconfig.build.json
@@ -1,4 +1,7 @@
{
"extends": "./tsconfig.json",
"include": ["./index.ts"]
}
"include": [
"./index.ts",
"./testing.ts"
]
}

0 comments on commit f8f44f4

Please sign in to comment.