question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

queryLoad does not use the provided variables

See original GitHub issue

@kitql/all-in version: 0.6.3

Problem: queryLoad does not load the data when the query expects a variable. I suspect the variable is not used even if provided. query works however. Also, using KitQLInfo, variables are null.

I have a simple my-query.graphql file, and generate all the types and stores with codegen as per your tutorial.

query GetResumeById($id: uuid!) {
	resumes_by_pk(id: $id) {
		id
		name
	}
}
<script context="module" lang="ts">
	import { browser, dev } from '$app/env'
	import { KQL_GetResumeById } from '$lib/data-access/graphql/_kitql/graphqlStores'
	
        export const hydrate = dev
	export const router = browser
	export const prerender = true
        
        // Does not work
	export async function load({ fetch }) {
		await KQL_GetResumeById.queryLoad({
			fetch,
                        variables: { id: 'fa69f955-ceab-4072-9e75-d25a07f27312' },
		}) // Filling the store
		return {}
	}
</script>

<script lang="ts">	
	import { KitQLInfo } from '@kitql/all-in'

        // works
	KQL_GetResumeById.query({
	 	fetch,
	 	variables: { id: 'fa69f955-ceab-4072-9e75-d25a07f27312' },
	})
</script>

<svelte:head>
	<title>About</title>
</svelte:head>
<KitQLInfo store={KQL_GetResumeById} />
<pre>{JSON.stringify($KQL_GetResumeById.data, null, 2)}</pre>

If I change the graphql file to hard-code the id, it works.

query GetResumeById {
	resumes_by_pk(id: "myid") {
		id
		name
	}
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gregoryforelcommented, Apr 7, 2022

I have no idea what’s going on. It’s solved now, but even comparing my branches I can’t see anything different that solved the issue. Maybe when I deleted Sveltekit’s cache or something. I’ll close for now, sorry for your time.

0reactions
gregoryforelcommented, Apr 6, 2022

I don’t have a repo to share but I guess I could put one together.

I’m 100% sure the id exists because the exact same query works when using load instead of queryLoad.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When variables change, data is the previous result in Query ...
I am using the "cache-and-network" policy. ... Since a query with different variables will not have cached data, but will have previous data ......
Read more >
Add and manage variables | Grafana documentation
Use a custom variable for a value that does not change, such as a number or a string. For example, if you have...
Read more >
Tables analysed by analyze_rsz_tables - SAP Community
All reusable query component (except variables) should be assigned to a particular InfoProvider. This assignment is located in the table ...
Read more >
Variable types - Amazon Managed Grafana
Using query variables, you can write a data source query that returns a list of ... Use a custom variable for values that...
Read more >
Reduce query load on access level preload (!66598) · Merge ...
alias is used because there's another join performed in projects_finder.rb. otherwise, ... If not an ActiveRecord, what else @projects variable can hold?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found