Comments (4)
Could you give me a quick example (pseudo code maybe) of how Relay would use this field? Also, would there be a deprecation plan for this? As it may eventually get removed as Relay removes this constraint?
The only reason I hesitate is I want a definitive resource to refer people to if they have questions about the viewer
field, maybe a documentation article would be nice? 😊
Otherwise, its super easy to do.
from crystal.
Sure, there's plenty of examples around. https://facebook.github.io/relay/docs/api-reference-relay-container.html gives a simple use case.
In routing (using react-router-relay):
const viewerQueries = {
viewer: () => Relay.QL`query { viewer }`,
};
const routes = (
<Route component={App}>
<Route path="/" component={Home} queries={viewerQueries} />
<Route path="/users" component={Users} queries={viewerQueries} />
<Route path="*" component={NotFound} />
</Route>
);
In a component:
// ...
export default Relay.createContainer(Home, {
fragments: {
viewer: () => Relay.QL`
fragment on User {
users {
// ...
${UsersTable.getFragment('users')}
}
}
}
`,
},
});
This allows you to re-use viewerQueries
for each container / top-level component, without having to know what the underlying data structure is beforehand.
As I said, this kind of approach makes perfect sense for view-driven GraphQL consumers like Relay, and I doubt there'll be a deprecation path necessary (even though there is talk about removing that restriction on the issue I posted above).
Now, I appreciate that this approach won't be required by normal GraphQL consumers that aren't necessarily view-driven (though there still is benefits to building up a graph query from a single entry node), so we should be careful not to break existing implementations.
from crystal.
See #49.
from crystal.
Released in 1.5.0
🙌
from crystal.
Related Issues (20)
- Smart tag to shortcut accessing an attribute from a related table
- Current enum value isn't present on GraphQLEnumType_values_value scope HOT 2
- Planned module: @dataplan/graphql HOT 4
- Significant memory spike in plugin with each() HOT 3
- Grafast: garbage collection
- Grafast: hoisting of subroutines
- Exported PgCodec loses polymorphic information HOT 3
- `withPgClient` is intended for mutations - make it clear! HOT 4
- PostGraphile docs: ambiguous example in makeExtendSchemaPlugin docs
- Document grafserv/envelop integration and how to add validation rules
- Graphile Export: detect hasOwn keys set on functions that aren't exportable
- Connection string with localhost don't work in library mode HOT 6
- "Gather" plugin example: treating unique indexes similarly to unique constraints HOT 1
- Document the new "early exit" and "global dependencies" features
- Epic: removing $step.eval()
- Masked errors when output to console should include path, etc.
- `makeWrapPlansAfterArgumentsHaveBeenAppliedPlugin` - solve confusion
- PostGraphileRelayPreset bug: mutation with "null" foreign key value does not work (returns null) HOT 1
- How does Postgraphile integrate with Apache AGE? HOT 1
- Polymorphism - union containing members of an interface plus another; how to plan?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crystal.