learning-graphql | An attempt to learn GraphQL | GraphQL library
kandi X-RAY | learning-graphql Summary
kandi X-RAY | learning-graphql Summary
This repository is my attempt to learn GraphQL by going through the official RFC specification and the sample JavaScript implementation. The Official Specification is meant for anyone who wants to implement GraphQL core in any language. I felt the need of a simpler version that speaks only JavaScript in its APIs and examples instead of being generic, so I wrote it down myself and shared with hope that others might find it useful too. Update: graphql.org site came out later, which took more straightforward approach to documenting it. I've updated the contents of this series taking a lot from this new dedicated site for GraphQL.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of learning-graphql
learning-graphql Key Features
learning-graphql Examples and Code Snippets
Community Discussions
Trending Discussions on learning-graphql
QUESTION
I had read through this great gist - GraphQLInterfaceType
But still have some confusions:
- Is that really necessary to define
ES6 classes
for all GraphQL schema types?- Main concern here is: we will end up with lots of empty
ES6 classes
and equivalent amount ofGraphQL types
.
- Main concern here is: we will end up with lots of empty
- If it is not, then how to handle the
resolveType
andisTypeOf
properly when use theinterfaces
features a lot? - Even I defined all the
ES6 classes
for all theGraphQL types
, but the raw data are constructed in different place with different tech likegrpc+protobuf
, which has no any relation to these classes definitions, so how does theisTypeOf: (value) => value instanceof Dog
work here?
ANSWER
Answered 2017-Apr-21 at 22:53The implementation of resolveType
and isTypeOf
is very flexible for a reason: it's extremely application-specific. It depends on the database, the data models, how similar the types are, and so on. Some backends might have separate ES6 classes for all their models, especially if using an ORM, where it creates instances of those classes when you query the database. But an ORM is not necessary. And you shouldn't be required to instantiate any other classes to figure out the GraphQL type.
In some cases, you can determine the type solely from the properties on the objects. If this isn't the case for your app, there are things you can do to give hints. Here is a SQL example.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install learning-graphql
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page