GraphQL for a single pdf file
See original GitHub issueI found documentation for querying all pdf files by using the allFile type, but I want to query a single pdf file. I haven’t been able to find any documentation on querying a single pdf file. This is what I have tried so far but I haven’t had any luck.
const data = useStaticQuery(graphql query { pdf: file(base: { eq: "resume.pdf" }) { publicURL } }
)
“a<href={this.props.data.pdf}>a”
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
How to return PDF file in an Graphql mutation? - Stack Overflow
It can't be done by mutation only. You can't return file(binary)/headers(mime)/etc (needed to be handled as download request behaviour by ...
Read more >File uploads and downloads in GraphQL | by Boštjan Cigan
This is a feature that allows you to upload files via GraphQL mutations directly. Not all server implementations support this, one of them...
Read more >GraphQL file uploads - evaluating the 5 most common ...
We're comparing the 5 most common approaches of uploading files with GraphQL APIs, using base64 encoding, Multipart uploads, a custom REST ...
Read more >GraphQL i - Tutorialspoint
tutorial will introduce you to the fundamental concepts of GraphQL including: ... Query type is one of the many root-level types in GraphQL....
Read more >Admin graphQL - Returning ID's for PDF files
Further investigation it actually seems to be falling over when it hits a PDF file. So even returning a MediaImage request for example, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@brandontb12 i’ve picked up on your issue and based on the information you mentioned in the description i’m going to detail a possible solution for your case. This will extrapolated from the information available.
gatsby-source-filesystem
gatsby-config.js
to the following:src\data
folder and copied over a sample pdf file calleda_random_example.pdf
src\pages\index.js
i changed it to the following:I’m fetching a single file, this time the pdf file i’ve mentioned and adding two links, the first one will display the pdf content and the second one will allow the pdf download. A small caveat regarding the second one. With the
gatsby-source-filesystem
package, the filename will be changed intoname-of-file-uuid.pdf
. I’ve issuedyarn develop
waited for the build process to complete and opening uphttp://localhost:8000
i’m presented with the following:As you can see in the left side is the “page” and on the right side the pdf being displayed.
Feel free to provide feedback so that we can close this issue, or continue to work on it until we find a suitable solution.
@brandontb12 ok, no need to thank, glad to hear it, feel free to close this as it’s fixed if you don’t mind.