Hi,
I am trying to use interfaces in my query using morpheus client. My gql file looks something like (excluded some excessive detail. Let me know if you want my full file):
"""
An object with an ID.
"""
interface Node {
"""
ID of the object.
"""
id: ID!
}
"""
Represents a Git object.
"""
interface GitObject {
id: ID!
}
"""
Represents a Git reference.
"""
type Ref implements Node {
id: ID!
"""
The object the ref points to.
"""
target: GitObject!
}
type Commit implements GitObject & Node {
id: ID!
"""
Authorship details of the commit.
"""
author: String
}
type Tree implements GitObject & Node {
"""
A list of tree entries.
"""
treeName: String
id: ID!
}
And my query looks something like:
defineByDocumentFile
"../resource/minimal-github.graphql"
[gql|
query FetchRepoHeadCommit ($repoOwner: String!, $repoName: String!) {
repository(name: $repoName, owner: $repoOwner) {
defaultBranchRef {
target {
... on Commit {
author
}
}
}
}
}
|]
This fails with Fragment cannot be spread here as objects of type \"GitObject\" can never be of type \"Commit\. Changing target: GitObject! to target: Commit! makes it work. This confuses me as I have type Commit implements GitObject.
My expectation is that this should work based on 2 from https://github.com/morpheusgraphql/morpheus-graphql#interface . Am I missing something?
Hi,
I am trying to use interfaces in my query using morpheus client. My gql file looks something like (excluded some excessive detail. Let me know if you want my full file):
And my query looks something like:
This fails with
Fragment cannot be spread here as objects of type \"GitObject\" can never be of type \"Commit\. Changingtarget: GitObject!totarget: Commit!makes it work. This confuses me as I havetype Commit implements GitObject.My expectation is that this should work based on
2from https://github.com/morpheusgraphql/morpheus-graphql#interface . Am I missing something?