Closed orlowdev closed 4 years ago
My apologies, everything works great! Ignore me 😂
was it perhaps
edges {
node {
[stuff goes here]
}
}
instead of
nodes {
[stuff goes here]
}
?
No, not really. It was just me having a token that cannot access things I tried to get via GraphQL. This caused the query to get nothing from GitHub, which, in turn, made githubData
to have no data
property. Without it in place, the whole query failed. As it had the type it couldn't understand (Blob), it failed to even start the dev server. That's all, folks 😆
@priestine So I assume that not enough privileges was set for token ? I am asking as I am having the same issue with unrecognized type Blob on my side
@GarciaPL, for me a new token fixed the problem. I managed to debug the token issue by removing all the keys in the query related to packages and it worked for me. If you still have issues, read the description of the package carefully, for me it worked.
Things to be attentive to:
gatsby-config.js
you put the query that fetches all the data from GitHub at once on gatsby develop
repositories(isFork: false) {...
in gatsby-config.js
should be then used in the code as repositories {...
Blob
in the actual code as you already have all the stuff needed/___grapql
on your host), especially the githubData
. If there's no data
inside, it means that your GitHub query in gatsby-config.js
failed for some reasonYou can also take a look at the orlove.dev repo in my profile, in gatsby-config.js
and src/pages/index.tsx
.
I hope these tips will help. Cheers!
@priestine thank you for your help! Now everything works as expected, much appreciated! :100:
Glad I could help. 👍
@priestine Apologize, but I was wrong that it works. It does for sure for the simple case of graphql without spreading used on types like getting info about user etc. When I have below graphql query defined in gatsby-config.js
which just returns blob of the files defined in the given repository. This query works in GitHub GraphQL API
graphQLQuery: `
query {
repository(owner: "CodingVoodoo", name: "template") {
object(expression: "master:") {
... on Tree {
entries {
name
type
object {
... on Blob {
text
}
}
}
}
}
}
}
`
it gives me two errors
Unknown type "Tree".
GraphQL request:7:20
6 | object {
7 | ... on Tree {
| ^
8 | entries {
and
Unknown type "Blob".
GraphQL request:12:26
11 | object {
12 | ... on Blob {
| ^
13 | text
Of course I am using query without parameters like
export const query = graphql`
query {
githubData {
data {
repository {
object {
... on Tree {
entries {
name
type
object {
... on Blob {
text
}
}
}
}
}
}
}
}
}
`
Would you be so kind and highlight where the problem is ? Only what I have found is that perhaps I need to create type definition as here specified Gatsby Creating type definitions
Try this query in the code:
query {
githubData {
data {
repository {
object {
entries {
name
type
object {
text
}
}
}
}
}
}
}
It should work.
Thank you! I would never find out that it should look like that. It works now! Thank you once again!
Sure, np. I’m not an expert in the topic but the to me underlying idea here is that at your app launch the GitHub query is executed, producing a new GraphQL schema where the data already has the shape that was returned from github. Thus you no longer have the blob and other stuff. Maybe I’m wrong. 😁
Hey! I really liked this little conversation.
I'll try adding a small FAQ in the readme with the things you discovered to make it easier for other devs using this package.
Otherwise, consider this issue closed (but feel free to add more comments if you want)
Hi guys. I got a problem with extracting readme from my repos. I tried the following query:
It doesn't start and throws the message:
I've tested the query in GitHub GraphQL API Explorer and the query itself is valid and it works. Is it me doing something wrong? Any help would be greatly appreciated. Thanks!