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)
- Postgraphile plugin connection filter export to schema functionality pull request
- Multiple pgServices yields 'Attempted to add a second codec named 'varchar[]''
- Polymorphic types non-nullable attributes not working
- Weird behavior when setting pgServices.name HOT 2
- `@ref` should allow specifying the `from` so single-table polymorphism can apply refs to a single type
- Raise a GraphQL.js PR to allow enum values to be a callback HOT 2
- Comments on computed column functions are not present in the resulting GraphQL schema HOT 3
- Functions that return a specific polymorphic type
- Extra metadata to handle `@ref` relations for non-nullable relations plugin HOT 1
- Ruru incorrectly templates array values as singular HOT 1
- Error: New error HOT 2
- Outdated `chalk` dependency breaks `Postgraphile` when running with `--disable-proto=delete` or using `Deno` HOT 3
- Stack traces are displayed in production and can't be disabled HOT 1
- Plans returning constant(true) throw a step mis-match error
- Enums not matched in postgraphile.tags.json5 HOT 4
- Forbid exploring steps' dependencies during planning HOT 4
- Error when trying to add a directive with any arguments via makeExtendSchemaPlugin HOT 3
- Ruru headers are not passed along with requests to `/graphql/stream` HOT 4
- Intended way to return a union like `union Result = User | UsernameTaken | ...` in v5? HOT 2
- Set bodySizeLimit for graphile v5 HOT 4
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.