-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected '__typename not found on object' #509
Comments
hi @AlistairB. please checkout #511 |
Thanks! This works if I change the query to: defineByDocumentFile
"../resource/minimal-github.graphql"
[gql|
query FetchRepoFile ($repoOwner: String!, $repoName: String!, $expression: String!) {
repository(name: $repoName, owner: $repoOwner) {
object(expression: $expression) {
__typename
... on Blob {
isTruncated
text
}
}
}
}
|] This works for me as a solution. However, if I don't add I could be wrong though. Happy to close if you think this is the right solution. |
@AlistairB you are right, i fixed that too. please checkout #512 |
Unfortunately this is still producing the same error unless I manually include I have updated master on https://github.com/AlistairB/morpheus-repro to reproduce the issue. As per https://github.com/AlistairB/morpheus-repro/blob/master/src/Lib.hs#L50-L52 , you will need to create a github personal access token. Then you can reproduce the issue with |
Hi, I've been playing with this a little bit more and noticed another minor issue. In the morpheus-repro example, the master version of morpheus will generate the following type: data RepositoryObjectGitObject
= RepositoryObjectGitObject {__typename :: Text} |
RepositoryObjectBlob {__typename :: Text,
isTruncated :: Bool,
text :: (Maybe Text)}
deriving Generic
deriving Show
deriving Eq A sum type with record accessors is considered a bit of an anti-pattern. This is because I pushed a new commit to https://github.com/AlistairB/morpheus-repro with the warning enabled to demonstrate the issue. One solution is just to exclude the accessors, but this would get ugly if you had a lot of fields returned. I think the ideal solution would be something like: data RepositoryObjectGitObject
= RepositoryObjectGitObject RepositoryObjectGitObjectValues
| RepositoryObjectBlob RepositoryObjectBlobValues
deriving (Generic)
deriving (Show)
deriving (Eq)
data RepositoryObjectGitObjectValues = RepositoryObjectGitObjectValues {repositoryObjectGitObjectValues__typename :: Text}
data RepositoryObjectBlobValues = RepositoryObjectBlobValues
{ repositoryObjectBlobValues__typename :: Text, -- actually we need to prefix this now as there can't be overlapping `__typename`. Unless DuplicateRecordFields is enabled.
isTruncated :: Bool,
text :: (Maybe Text)
} Anyway, as mentioned I think this is minor. It could be a separate issue (I can create if you want), or not worried about. Just thought I'd mention it. |
hi @AlistairB ,
please address it in different issue :)
i checked this out. i will address this problem later, as long as it is not as trivial as i thought |
finally fixed it. see #773 |
Hi, possibly related to #493
I got around to using the changes for this feature. They are compiling as expected, however now I am getting a runtime error.
My query looks like:
You can see the schema I am using here https://github.com/AlistairB/morpheus-repro/blob/master/minimal-github.graphql .
The error I am getting:
Error in $.data.repository.object: key \"__typename\" not found on object
Running this in the github graphql explorer, eg. this query:
produces this response:
I can include
__typename
in the query and will get back in the response"__typename": "Blob"
(via the github graphql explorer).Adding
__typename
to the query that morpheus is using causes compile time errors eg.Error: \"cant find field DataInterface
.Is this enough info? If not I can set up a repro in https://github.com/AlistairB/morpheus-repro
The text was updated successfully, but these errors were encountered: