Comments (10)
Branch dynamic-interface
supports the flatten
property, we may need sufficient validation to merge to the master
, because this will break the type safety of the interface.
Here are all the tests:
Line 4 in 8714185
Line 41 in 8714185
Line 73 in 8714185
from async-graphql.
This is pretty easy to implement, but I can't make an object that contains the flatten fields support Interface
.😭
from async-graphql.
Does that mean you cannot support the flatten attribute on interfaces or objects that use flatten cannot implement an interface? I think having flatten would kind of sort #35 in that you can combine a SimpleObject with an Object.
from async-graphql.
Yes, it's the same problem. I can't pass data between macros, which makes it impossible. But all of these problems can be solved with generic specialization, so let's wait for this feature to stabilize. 😂
from async-graphql.
So I poked around a little in the code base. I tried to manually (without macros) implement an "Object" by implementing ObjectType, OutputValueType and Type on a struct. I can't quite get create_type_info
to work correctly but I thought it should be possible to create a trait Merge
with required methods async fn base(&self) -> impl ObjectType
and async fn extend(&self) -> impl ObjectType
and then implement impl<T> ObjectType for T where T: Merge { ... }
so that it registers all fields on the object returned from a call to self.base()
and self.extend()
. Or maybe even a method like async fn objects(&self) -> Vec<Box<dyn ObjectType>>
. Could that work or have I hit a dead end?
from async-graphql.
The main reason is that Interface
cannot be supported. The field of Interface
is function forwarding, which can achieve the purpose of type safety.
from async-graphql.
If I don't need to support the Interface
, I've actually implemented it.😁
from async-graphql.
Unless you abandon the type-safety of the interface, which is not what this library is for.
from async-graphql.
The Edge
type actually does that, it moves the extra_type
to a higher level, but the field inside the extra_type
doesn't support interface.
fn Edge::node()
and fn Edge::cursor()
are actually intended to support the interface.
from async-graphql.
That is very nice! 👍
from async-graphql.
Related Issues (20)
- Get mutable referenece to the global data defined in the `Context` or `Schema` HOT 1
- Confusing `unused_mut` warning in `#[Object]` HOT 8
- How to handle both directions of one-to-many relation in federated graph
- Question: How to get server to send ping messages on subscriptions? HOT 2
- Parsing multiple operations in a file HOT 1
- Non nullable variables should allow default values HOT 3
- Object with single skipped field but with ComplexObject HOT 2
- As using proxy type
- Using flatten inside an impl with no other fields causes a compile error
- Subscription with MPSC receiver in context data
- Reduce clippy noise from #[Object] macro HOT 2
- Guard trait lifetime HOT 1
- Using generics with both SimpleObject and InputObject as field in output type fails HOT 1
- Subscription Authentication
- Stack overflow after upgrade to 7.0.2 HOT 5
- Does async-graphql validate responses?
- Error reading data from ExtensionContext after upgrade to 7.0.3 HOT 1
- Create a general error formateer
- Allow flatten on arguments
- External fields not getting generated in SDL
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 async-graphql.