RelayNode | A block-compressing fast relay server/client
kandi X-RAY | RelayNode Summary
kandi X-RAY | RelayNode Summary
See for information on the network.
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 RelayNode
RelayNode Key Features
RelayNode Examples and Code Snippets
Community Discussions
Trending Discussions on RelayNode
QUESTION
I'm using TypeScript for my React + Apollo project and I'm using the graphql-code-generator which generates the following types:
...ANSWER
Answered 2019-Oct-01 at 08:56You can't enforce this on a variable. A basic principle of OOP is that a a sub-type is assignable to a base type reference. Since typescript uses structural typing, the base type/sub type relationship is not explicit, but given the structure of GetProjectQuery['project']
and ProjectInput
, GetProjectQuery['project']
is a sub-type of ProjectInput
Now typescript sometimes intentionally violates the sub-type is assignable to base-type rule for very specific scenarios:
- Excess property checks - These kick in when an object literal is assigned directly to a typed reference and disallows any extra properties.
- For weak types (types with not mandatory properties) typescript warns if there is no overlap between types.
Your scenario is neither of these so you will not get an error.
If you want to perform this validation when you calling a function, then we can use a bit of generic type parameter magic to capture the actual type of the parameter and force an error on any extra properties:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install RelayNode
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