GraphQL getting filename,file content and commit date #24419
-
I’am able to get filename, file content and commit date from github using graphql by three queries. following are the querys :
How to get these three details by running one query? ie, for each file in github i need to get filename, file content and commit date of the file. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
From what I understand, you can’t get all three details by running one query. Since I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Hey @anvinraj! I believe the GraphQL API can do some of you’re looking for by using a feature called aliasing, which allows you to give connections a unique name, and execute multiple of the same connections in a single query. Take your example run against one of my Repositories:
This returns all three of them, in one query:
The only limitation in this is that you cannot use the output of one query into an input field in the same query. However, I do think that there are some optimizations to your query that can be done. For example, I believe you can go directly from the Tree to the object contents, by doing something like this:
Let me know if this makes sense, and if anything else looks amiss! I would also recommend using GraphQL Variables, which would allow you to paramaterize some of what you’re doing, instead of string concatenation. Let me know if you have any more questions! |
Beta Was this translation helpful? Give feedback.
-
I tried some queries but getting response as below? Any clue pls?
|
Beta Was this translation helpful? Give feedback.
-
Yes! You have a missing } at the end. { |
Beta Was this translation helpful? Give feedback.
-
Is there any way to get only the files changed in that specific commit? |
Beta Was this translation helpful? Give feedback.
-
Just kidding, this query gets all files in the repo…
|
Beta Was this translation helpful? Give feedback.
Hey @anvinraj!
I believe the GraphQL API can do some of you’re looking for by using a feature called aliasing, which allows you to give connections a unique name, and execute multiple of the same connections in a single query. Take your example run against one of my Repositories:
This returns all three of them, in one query: