graphql-typed-document-node icon indicating copy to clipboard operation
graphql-typed-document-node copied to clipboard

Support apollo-client ~3.5.0

Open smykhailov opened this issue 3 years ago • 5 comments
trafficstars

@dotansimha I try to upgrade apollo client on our codebase and realized there is no patch for Apollo client ~3.5.0. Are there any plans to add this version, or can I workaround it by creating my own patch?

smykhailov avatar Dec 06 '21 14:12 smykhailov

Hi @smykhailov I think you don't need a patch for 3.5.0, since it's built-in. Are you using the Component notation of the Apollo client? I guess that's the only need for a plugin?

dotansimha avatar Dec 08 '21 20:12 dotansimha

sorry, I don't know what is Component notation? As we use HOC (Query/Mutation/Subscription) I had to do patch to remove prop types and it works now as expected.

This one is still needed. everything works as expected with this patch on 3.5.5

diff --git a/node_modules/@apollo/client/react/components/Mutation.d.ts b/node_modules/@apollo/client/react/components/Mutation.d.ts
index 9288a7c..bf1dd98 100644
--- a/node_modules/@apollo/client/react/components/Mutation.d.ts
+++ b/node_modules/@apollo/client/react/components/Mutation.d.ts
@@ -1,12 +1,5 @@
 /// <reference types="react" />
-import * as PropTypes from 'prop-types';
 import { OperationVariables } from '../../core';
 import { MutationComponentOptions } from './types';
 export declare function Mutation<TData = any, TVariables = OperationVariables>(props: MutationComponentOptions<TData, TVariables>): JSX.Element | null;
-export declare namespace Mutation {
-    var propTypes: PropTypes.InferProps<MutationComponentOptions<any, any, import("../../core").DefaultContext, import("../../core").ApolloCache<any>>>;
-}
-export interface Mutation<TData, TVariables> {
-    propTypes: PropTypes.InferProps<MutationComponentOptions<TData, TVariables>>;
-}
 //# sourceMappingURL=Mutation.d.ts.map
\ No newline at end of file
diff --git a/node_modules/@apollo/client/react/components/Query.d.ts b/node_modules/@apollo/client/react/components/Query.d.ts
index 7577c29..64f5602 100644
--- a/node_modules/@apollo/client/react/components/Query.d.ts
+++ b/node_modules/@apollo/client/react/components/Query.d.ts
@@ -1,12 +1,5 @@
 /// <reference types="react" />
-import * as PropTypes from 'prop-types';
 import { OperationVariables } from '../../core';
 import { QueryComponentOptions } from './types';
 export declare function Query<TData = any, TVariables = OperationVariables>(props: QueryComponentOptions<TData, TVariables>): JSX.Element | null;
-export declare namespace Query {
-    var propTypes: PropTypes.InferProps<QueryComponentOptions<any, any>>;
-}
-export interface Query<TData, TVariables> {
-    propTypes: PropTypes.InferProps<QueryComponentOptions<TData, TVariables>>;
-}
 //# sourceMappingURL=Query.d.ts.map
\ No newline at end of file
diff --git a/node_modules/@apollo/client/react/components/Subscription.d.ts b/node_modules/@apollo/client/react/components/Subscription.d.ts
index c07aefd..4ec526b 100644
--- a/node_modules/@apollo/client/react/components/Subscription.d.ts
+++ b/node_modules/@apollo/client/react/components/Subscription.d.ts
@@ -1,12 +1,5 @@
 /// <reference types="react" />
-import * as PropTypes from 'prop-types';
 import { OperationVariables } from '../../core';
 import { SubscriptionComponentOptions } from './types';
 export declare function Subscription<TData = any, TVariables = OperationVariables>(props: SubscriptionComponentOptions<TData, TVariables>): JSX.Element | null;
-export declare namespace Subscription {
-    var propTypes: PropTypes.InferProps<SubscriptionComponentOptions<any, any>>;
-}
-export interface Subscription<TData, TVariables> {
-    propTypes: PropTypes.InferProps<SubscriptionComponentOptions<TData, TVariables>>;
-}
 //# sourceMappingURL=Subscription.d.ts.map
\ No newline at end of file

smykhailov avatar Dec 09 '21 20:12 smykhailov

sorry, I don't know what is Component notation?

As we use HOC (Query/Mutation/Subscription) I had to do patch to remove prop types and it works now as expected.

This one is still needed. everything works as expected with this patch on 3.5.5


diff --git a/node_modules/@apollo/client/react/components/Mutation.d.ts b/node_modules/@apollo/client/react/components/Mutation.d.ts

index 9288a7c..bf1dd98 100644

--- a/node_modules/@apollo/client/react/components/Mutation.d.ts

+++ b/node_modules/@apollo/client/react/components/Mutation.d.ts

@@ -1,12 +1,5 @@

 /// <reference types="react" />

-import * as PropTypes from 'prop-types';

 import { OperationVariables } from '../../core';

 import { MutationComponentOptions } from './types';

 export declare function Mutation<TData = any, TVariables = OperationVariables>(props: MutationComponentOptions<TData, TVariables>): JSX.Element | null;

-export declare namespace Mutation {

-    var propTypes: PropTypes.InferProps<MutationComponentOptions<any, any, import("../../core").DefaultContext, import("../../core").ApolloCache<any>>>;

-}

-export interface Mutation<TData, TVariables> {

-    propTypes: PropTypes.InferProps<MutationComponentOptions<TData, TVariables>>;

-}

 //# sourceMappingURL=Mutation.d.ts.map

\ No newline at end of file

diff --git a/node_modules/@apollo/client/react/components/Query.d.ts b/node_modules/@apollo/client/react/components/Query.d.ts

index 7577c29..64f5602 100644

--- a/node_modules/@apollo/client/react/components/Query.d.ts

+++ b/node_modules/@apollo/client/react/components/Query.d.ts

@@ -1,12 +1,5 @@

 /// <reference types="react" />

-import * as PropTypes from 'prop-types';

 import { OperationVariables } from '../../core';

 import { QueryComponentOptions } from './types';

 export declare function Query<TData = any, TVariables = OperationVariables>(props: QueryComponentOptions<TData, TVariables>): JSX.Element | null;

-export declare namespace Query {

-    var propTypes: PropTypes.InferProps<QueryComponentOptions<any, any>>;

-}

-export interface Query<TData, TVariables> {

-    propTypes: PropTypes.InferProps<QueryComponentOptions<TData, TVariables>>;

-}

 //# sourceMappingURL=Query.d.ts.map

\ No newline at end of file

diff --git a/node_modules/@apollo/client/react/components/Subscription.d.ts b/node_modules/@apollo/client/react/components/Subscription.d.ts

index c07aefd..4ec526b 100644

--- a/node_modules/@apollo/client/react/components/Subscription.d.ts

+++ b/node_modules/@apollo/client/react/components/Subscription.d.ts

@@ -1,12 +1,5 @@

 /// <reference types="react" />

-import * as PropTypes from 'prop-types';

 import { OperationVariables } from '../../core';

 import { SubscriptionComponentOptions } from './types';

 export declare function Subscription<TData = any, TVariables = OperationVariables>(props: SubscriptionComponentOptions<TData, TVariables>): JSX.Element | null;

-export declare namespace Subscription {

-    var propTypes: PropTypes.InferProps<SubscriptionComponentOptions<any, any>>;

-}

-export interface Subscription<TData, TVariables> {

-    propTypes: PropTypes.InferProps<SubscriptionComponentOptions<TData, TVariables>>;

-}

 //# sourceMappingURL=Subscription.d.ts.map

\ No newline at end of file

Yeah that <Query> thing is the Component notation. Legacy PropTypes breaks generic inference :(

dotansimha avatar Dec 09 '21 20:12 dotansimha

should I create a patch for 3.5 and merge here?

smykhailov avatar Dec 15 '21 20:12 smykhailov

should I create a patch for 3.5 and merge here?

That would be great, thank you!

I really want Apollo-Client to drop the PropTypes thing, it breaks some TS features because it's no longer the recommended way to type the props of React.

dotansimha avatar Dec 16 '21 08:12 dotansimha