how to do inline fragments?
capaj opened this issue · 3 comments
capaj commented
on our Graphql api we use interfaces. To query an interface we need to make inline fragments such as:
query HeroForEpisode($ep: Episode!) {
hero(episode: $ep) {
name
... on Droid {
primaryFunction
}
... on Human {
height
}
}
}
if this lib can support these we can start putting it to production at https://www.looop.co/
acro5piano commented
Production application is the goal to OSS!
I haven't used inline fragments, so take a look tomorrow.
Thanks,
capaj commented
huh now that I am thinking about this-we could use the same approach I was suggesting for #2 and do:
import {fragment} from 'typed-graphqlify'
const queryObject = {
hero: fragment({name: types.string}, {
Droid: {
primaryFunction: types.string,
},
Human: {
height: types.number,
}
})
}
so fragment would take 2 params-first would be common fields and the second would have interface types and their respective fields. It should be possible to express the return type of that in typescript I think.
acro5piano commented
close as #28 merged.