-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Proposal: Client side schema, resolvers and mutations #274
Comments
I don't think this requires any new graphql stuff right? Could just use an @client directive. We almost implemented this in Apollo but it ended up not being a priority. I'd be happy to work together to make this happen! |
Ah, so @stubailo you mean like this? query getCards {
cards @export(as: "cards") {
_id
name
}
}
query @client getWizardStep($route: Route, $location: Location) {
stepState: calcWizardStep(route: $route, location: $location, cards: $cards) {
currentCard
cardCount
}
} And until there's support for the export directive this could work? import { compose, graphql } from 'react-apollo';
import gql from 'graphql-tag';
import WizardStepComponent from '.';
export default compose(
grapqhql(gql`
query getCards {
cards
_id
name
}
}
`),
grapqhql(gql`
query @client getWizardStep($route: Route, $location: Location, $cards: Cards) {
stepState: calcWizardStep(route: $route, location: $location, cards: $cards) {
currentCard
cardCount
}
}
`, { options: ({ data: { cards = [] } }) => ({ variables: { cards } }) }),
)(WizardStepComponent); |
Yep! I was actually thinking @jnwng was interested in this as well! Here's the original PR that we didn't end up fully merging (that's where the current custom resolvers come from) I'd love to bring that back and make it a real thing! apollographql/apollo-client#809 |
I agree that directives should provide what you need, and no changes are necessary to graphql to do what you're looking to do. In fact you may be able to do this without any directives at all - we use client specific fields using the experimental |
As mentioned in this thread: apollographql/apollo#75 (comment)
It would be terrific to be able to combine states in a client side graphql implementation.
For example we often have situations where we depend on server side data and client side route information and other client side resources. It is really hard right now to combine them in a well documented and clear way, we see different solutions to this problem every day.
So our suggestion is to be able to have a client side version of graphql with the root query being named "client" instead of "query" and being able to pass down variables created by previous queries to other "query" or "client" implementations in a serial synchronous fashion.
Here's an example of what this could look in a query:
The text was updated successfully, but these errors were encountered: