How to use g-image with graphQL?
See original GitHub issueIt feels like we need a community somewhere to ask questions like mine here, but anyway. There seems to be some info missing in the documentation about g-image and how to use it with graphQL.
The section here https://gridsome.org/docs/images#usage-via-graphql does not state how to format the src link. So what should the link look like to work?
After a lot of googling and searching I got it working by writing it like this:
<g-image :src="require(`!!assets-loader?width=552!@/${edge.node.image1}`)" width="552" />
But that was a very ugly way of doing it, so is there a nicer way to do this?
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Images - Gridsome
#Usage via GraphQL. Local image paths from sources can also be compressed. Options like width , height and quality must be set in...
Read more >Image management via GraphQL by Tamas Piros
In this article, we'll review how to manage images using GraphQL by discussing an application that utilises GraphQL queries and mutations to ...
Read more >Gridsome Remote GraphQL Source - CodeSandbox
CodeSandbox is an online editor tailored for web applications.
Read more >Gridsome Graphql filter variable - vue.js - Stack Overflow
Im trying to query a collection and filter it depends on the $path var but it either returns empty or throwing an error...
Read more >Blazing-Fast Vue and GraphQL with Gridsome - Reed Barger ...
Concepts Cover: - How to build incredible apps with Vue and GraphQL using ... responsive images with g-image Adding data sources to GraphQL...
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 Free
Top 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
Only local, relative image paths will be compressed when using
g-image
when thesrc
attribute points to a local file like:<g-image src="../assets/image.jpg" />
.But when adding nodes to the GraphQL layer, you need to use an absolute file path. There are various methods for getting an absolute path like
path.resolve
,path.join
orrequire.resolve
:I understand your concerns. We are trying to catch up features in other SSGs out there, but I’m not sure when we will reach v1.0 yet. Hopefully, it’s not too far away.
We have only tested Gridsome with 10k pages so far, which works fine, but I’m not sure if it’s ready for 500k. Our goal is to make it work and support incremental builds to only build what’s necessary on re-builds. But that features isn’t implemented yet…
Sorry for not having any ETAs. We are eager to get things done, but it takes time… 😃