Comments (5)
The problem is that you would end up extending the types here and there and then question yourself, why does the userType suddenly have x and y fields and where do they even come from? Then you will have to search all of your code to find that it's the userQueryType that did that
We can accept it as a schema manipulation utility, but not as a user-facing tool that we would suggest using
We will have to update the interface implementation anyways and this is where your effort could be more useful (You can then add your extend method later)
from garph.
The GraphQL spec describes a concept of extensions. We will have to support it as well, if we want to be compatible with the spec
https://spec.graphql.org/October2021/#sec-Object-Extensions
I will update my implements
feature and once it is ready, you can try to add the extend
to the types that support extensions, namely: object type, interface type, union, enum, input
from garph.
Hey Mubarak, thanks for starting the issue 😁
Why not use interfaces instead? Any scenario, where your approach could be more useful?
const userExtend = g.interface('UserExtend', {
createdAt: g.string(),
updatedAt: g.string()
});
const userType = g.type('User', {
id: g.string(),
email: g.string(),
name: g.string().optional(),
}).implements(userExtend)
from garph.
Hi Mish! Thanks for your comment and suggestion. Using interfaces is certainly another way to extend the schema definition without duplicating the fields. In this case, we chose to use the extend method because it allows us to keep the schema definition in one place (userType object) and extend it only where necessary (userQueryType object).
However, I can see how using interfaces can be useful in some scenarios, especially if we have multiple types that need to share the same extended fields. It's always good to have multiple options and use the one that fits the situation best.
Thanks again for your input!
from garph.
Added in 0.6.3
from garph.
Related Issues (20)
- Dedicated support for loaders HOT 9
- Input type should be able to specify a default value
- Automatic Filters HOT 1
- Automatic Pagination HOT 1
- Implementation-first API
- Semantics
- Drizzle Integration HOT 6
- Add auth examples
- Organizing complex projects
- Using garph's inbuilt relay schema builder types results in type errors. HOT 1
- Extending root-types HOT 4
- g.scalar does not support optional() HOT 6
- Type inference issues when organizing resolvers in separate files HOT 2
- Name collisions can result in somewhat obscure errors
- Support for self referential types HOT 2
- Augment resolved types with internal properties HOT 13
- how to insert more field after accrss paginatedList() HOT 1
- Make builtin types lazy HOT 2
- Inferred types for subscriptions is incorrect
- inputType type reference not work well (can only resolved with scalar type) HOT 3
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 garph.