You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to request a new feature to change operation when executing Query/Mutation/Subscription.
It satisfies the following:
It can change operation.query. It can add and remove arguments and fields.
it can change operation.variables.
it can change operation.context(using operation.setContext()/operation.getContext()). This is because there are cases where I want to change the operation.query using the context.
It can update the cache based on the changed operation.
Background
I'm working on a library to make Apollo Client more useful with Relay Specification.
The library includes an improved relayStylePagination, many directives such as @arguments and @argumentDefinitions, and hooks such as usePaginationFragment.
The library can infer more information than what the user wrote in a query because the Relay Specification has some conditions in the schema.
So, it is theoretically possible for the library to automatically added fields to the user's query.
For example, there is always the field called pageInfo in Connection, so if the user has not written this field, it can be added automatically.
Issue
I have implemented several features such as @arguments and @argumentDefinitions by changing operation.query and operation.variables in Link.
However, this is not the recommended way and there is an issue.
The issue is that fields and arguments that were not present in the initial query cannot be found in the cache. apollographql/apollo-client#8384
So I can't implement a case where the library adds pageInfo and uses its value.
Ideas
The first idea is to make it possible to change the query and variables in Link.
Another idea is to create a new feature that makes it possible to change operation.
For example, introduce operationModifier like the following:
If operationModifier is not empty, the client will execute them before requesting the API. The cache will be updated based on the changed operation.
I'm very interested in this feature. If you are busy, I can try to implement it if we can agree on some design.
The reason I like Apollo Client is its extensibility, so I hope this request will create more possibilities for Apollo Client.
The text was updated successfully, but these errors were encountered:
Summary
From: apollographql/apollo-client#8384
I would like to request a new feature to change
operation
when executing Query/Mutation/Subscription.It satisfies the following:
operation.query
. It can add and remove arguments and fields.operation.variables
.operation.context
(usingoperation.setContext()
/operation.getContext()
). This is because there are cases where I want to change theoperation.query
using the context.operation
.Background
I'm working on a library to make Apollo Client more useful with Relay Specification.
The library includes an improved
relayStylePagination
, many directives such as@arguments
and@argumentDefinitions
, and hooks such asusePaginationFragment
.The library can infer more information than what the user wrote in a query because the Relay Specification has some conditions in the schema.
So, it is theoretically possible for the library to automatically added fields to the user's query.
For example, there is always the field called
pageInfo
in Connection, so if the user has not written this field, it can be added automatically.Issue
I have implemented several features such as
@arguments
and@argumentDefinitions
by changingoperation.query
andoperation.variables
in Link.However, this is not the recommended way and there is an issue.
The issue is that fields and arguments that were not present in the initial query cannot be found in the cache.
apollographql/apollo-client#8384
So I can't implement a case where the library adds
pageInfo
and uses its value.Ideas
The first idea is to make it possible to change the query and variables in Link.
Another idea is to create a new feature that makes it possible to change
operation
.For example, introduce
operationModifier
like the following:If
operationModifier
is not empty, the client will execute them before requesting the API. The cache will be updated based on the changedoperation
.I'm very interested in this feature. If you are busy, I can try to implement it if we can agree on some design.
The reason I like Apollo Client is its extensibility, so I hope this request will create more possibilities for Apollo Client.
The text was updated successfully, but these errors were encountered: