Provider documentation
Hygraph
Transform assets from a Hygraph project delivery endpoint.
Setup
Install the framework package and the core package for the provider import:
npm install @desource/image @desource/image-svelte Save this as image.config.ts beside your example component. Replace sample domains and identifiers with
your own.
import type { ImageConfig } from '@desource/image';
import { hygraphProvider } from '@desource/image/providers/hygraph';
export const imageConfig = {
provider: 'hygraph',
providers: {
hygraph: hygraphProvider({
"baseURL": "https://eu-central-1-shared-euc1-02.graphassets.com/your-environment-id"
})
}
} satisfies ImageConfig; Registering this provider makes it the default for the configured components. To mix services, register each
provider and set provider="hygraph" on the image that should use this one.
Image source
With the base ID in baseURL, pass the asset ID. Otherwise src must include both base ID and asset ID.
your-asset-idUsage
The example uses the shared configuration above and the Svelte image component.
<script lang="ts">
import { Image, setImageConfig } from '@desource/image-svelte';
import { imageConfig } from './image.config';
setImageConfig(imageConfig);
</script>
<Image
src="your-asset-id"
alt="Sample image" width={800} height={500}
modifiers={{
"format": "webp",
"quality": 80,
"fit": "contain"
}}
/>Provider options
Pass shared defaults such as screens, domains, aliases and presets to the image configuration. Pass provider-specific defaults as modifiers in the provider factory.
Modifiers
Supports width, height, fit, format and quality. Fit contain becomes max. Format defaults to auto_image; explicit formats use output=format:{format}.
Set dimensions on the component and pass service-specific operations through modifiers, as shown
above. See the provider source for exact mappings and the service documentation for accepted values.
Provider notes
- Quality is only included when an explicit output format is requested.
- Missing baseURL or an invalid source path throws an error. Copy the asset endpoint from your Hygraph project.