Comments (13)
Is there any example tackling basic union
types?
from graphql-yoga.
@eliperelman would you be open to adding an example via PR demonstrating how to use interfaces + unions?
from graphql-yoga.
hello
Who want to learn Prisma or contribute in our Project?:
We have got a ready react-native project who use prisma already setup with all techno apollo2 webpack4 react-scripts inside:
It's here
https://github.com/simonjoom/react-native-project
Read README, We are ready to hire competent and efficient developper who use prisma API CRUD in efficient way for our project
from graphql-yoga.
@maticzav is this helpful?:
from graphql-yoga.
@schickling I've written a medium post covering Interfaces / Unions with Prisma & Yoga. Let me know which is the best way, if any, for me to help take parts of that and add to the docs. Also if there are any additions, clarifications, errors in my post, happy to correct things.
https://medium.com/@tibotiber/graphql-interfaces-and-union-types-with-prisma-and-yoga-7224f9e1d9ad
from graphql-yoga.
Thanks a lot for this great blog post @tibotiber! Would be great if you could create a PR adding an example demonstrating how to use interfaces + unions. 🙏
from graphql-yoga.
Hey stale bot, you happen to be right. I think we're done here as docs has been added to cover the question. Since I opened, I'll close :). 👋
from graphql-yoga.
I just ran into this too...
EDIT:
never mind... doh.
you need to provide a _resolveType function for union types
less magical than I thought but at least now it's not a mystery how it determines the type lol
from graphql-yoga.
@idibidiart do you mind expending on your solution?
from graphql-yoga.
When you implement your resolvers, all 'standard' keys for it are available, so fragment
, resolve
, __resolveType
and __isTypeOf
:
export interface IResolverOptions {
resolve?: IFieldResolver<any, any>;
subscribe?: IFieldResolver<any, any>;
__resolveType?: GraphQLTypeResolver<any, any>;
__isTypeOf?: GraphQLIsTypeOfFn<any, any>;
}
from graphql-yoga.
Sorry didn’t see this before. I used __resolveType for efficient resolution. I assume isTypeOf is a hint field that has to be in the entity or API being queried but I’m not sure. I think you have to specify how to differentiate types. I’m not sure if GraphQL actually has pattern matching to resolve the different types in a Union all on its own. I don’t think that scales for long lists.
from graphql-yoga.
@eliperelman this is super useful! Thanks!
from graphql-yoga.
Due to inactivity of this issue we have marked it stale
. It will be closed if no further activity occurs.
from graphql-yoga.
Related Issues (20)
- Error when aborting subscription with µWebSockets.js HOT 2
- graphql-yoga with gqtx docs HOT 2
- Unexpected order of properties in response HOT 1
- Fastify Context & schema TS types. HOT 1
- Project Roadmap
- Project Roadmap
- Network request is dropped after the first event is emitted on the Subscription over HTTP SSE HOT 1
- [plugins/prometheus] missing operation name in graphql_yoga_http_duration_count metric on status 400
- [integrations/fastify] Add documentation to enable SSE subscriptions HOT 4
- [useResponseCache] Provide server context to define session Id HOT 3
- docs(Getting started): Suggest code snippets that work without changes HOT 1
- `Must provide query string.` should not be an error HOT 6
- Project Roadmap
- Project Roadmap
- Document `waitUntil` function present in the server context
- [managed-federation] New plugin: `useManagedFederation` which loads and keeps up to date a GraphOS managed supergraph
- Typescript build fails for project using `type: module`
- uWebSockets duplicate set-cookie responses
- Add support for GraphiQL initial tabs HOT 2
- Setting `maskedErrors` to `true` in `development` mode has no effect HOT 2
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 graphql-yoga.