-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Pluggable query transforms #233
Conversation
…ST and changed the definition of QueryTransformer
@@ -51,7 +51,8 @@ | |||
"lodash.isstring": "^4.0.1", | |||
"lodash.isundefined": "^3.0.1", | |||
"redux": "^3.3.1", | |||
"symbol-observable": "^0.2.4" | |||
"symbol-observable": "^0.2.4", | |||
"to-iso-string": "0.0.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this
let queryDef = getQueryDefinition(query); | ||
// Apply the query transformer if one has been provided. | ||
if (this.queryTransformer != null) { | ||
queryDef = applyTransformerToQuery(queryDef, this.queryTransformer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want to do this on mutations as well!
I think we should make this apply to mutations as well, then it will be good to merge! |
@stubailo added the mutation transform stuff as well - could you take a look? |
@@ -88,7 +94,8 @@ export class QueryManager { | |||
private store: ApolloStore; | |||
private reduxRootKey: string; | |||
private pollingTimer: NodeJS.Timer | any; // oddity in typescript | |||
|
|||
private queryTransformer: QueryTransformer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these need to be two separate options, since I can't think of any reason they would be different. Let's just call it queryTransformer
and use the same one in both places.
Yeah I think we can just use the same option for queries and mutations, at least until we find a good reason to keep them separate. |
To make this feature usable, we also need to add this option to |
Just updated w/ the client option and removed the MutationTransformer thing - @stubailo could you review? |
const mutationDef = getMutationDefinition(mutation); | ||
const mutationString = print(mutation); | ||
let mutationDef = getMutationDefinition(mutation); | ||
if (this.queryTransformer != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (this.queryTransformer) {
Is the best way to do this, I think.
Looks great - just add the change to the changelog and make the suggested style modification, and we're good to go! |
Oh, and don't forget to rebase on master. |
…ST and changed the definition of QueryTransformer
Fix typos in cache-updates.md
Added a way to plug a query transform function into the QueryManager constructor so that fields other than just
__typename
can be added to the query AST.#230
TODO: