Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support apollo-client ~3.5.0 #127

Open
smykhailov opened this issue Dec 6, 2021 · 5 comments
Open

Support apollo-client ~3.5.0 #127

smykhailov opened this issue Dec 6, 2021 · 5 comments

Comments

@smykhailov
Copy link

@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?

@dotansimha
Copy link
Owner

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?

@smykhailov
Copy link
Author

smykhailov commented Dec 9, 2021

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

@dotansimha
Copy link
Owner

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 thing is the Component notation. Legacy PropTypes breaks generic inference :(

@smykhailov
Copy link
Author

should I create a patch for 3.5 and merge here?

@dotansimha
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants