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.

Support query outside of pages and layouts

See original GitHub issue

I have not yet had success with fetch queries to my remote graphql server (Hasura). I’m getting a Cannot read property 'data' of undefined error, and after adding logging to the environment.js my best guess is that it’s not even attempting to fetch since the logging isn’t appearing. I’m not clear on the best way to debug this issue, and am hoping a solution here will help others.

My query is adapted straight from the documentation:

	import { query, graphql, AllUsers } from '$houdini';
	const { data } = query<AllUsers>(graphql`
		query AllUsers {
			kl_users {
				email
				uid
			}
		}
	`);

and the error is:

Cannot read property 'data' of undefined
TypeError: Cannot read property 'data' of undefined
    at Module.query (/$houdini/runtime/query.js:15:48)
    at Login.svelte:33:29
    at Object.$$render (<PATH>/node_modules/svelte/internal/index.js:1380:22)
    at eval (/src/lib/layout/Header.svelte:15:115)
    at Object.$$render (<PATH>/node_modules/svelte/internal/index.js:1380:22)
    at eval (<PATH>/src/routes/$layout.svelte:42:94)
    at Object.$$render (<PATH>/node_modules/svelte/internal/index.js:1380:22)
    at root.svelte:31:44
    at $$render (<PATH>/node_modules/svelte/internal/index.js:1380:22)
    at Object.render (<PATH>/node_modules/svelte/internal/index.js:1388:26)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AlecAivaziscommented, May 19, 2021

@thormuller I ran into something interseting while debugging this - if I change /src/routes/qry/index.svelte to look like

<script>
	import { query, graphql } from '$houdini';
	const { data } = query(graphql`
		query AllUsers {
			kitchenlab_users {
				email
				uid
			}
		}
	`);
</script>

{$data.kitchenlab_users.length}

Then I see the query being fired and a result is rendered. I’m going to keep poking at this to see if i can figure out the difference between this page the Login component but at least there is some progress.

edit: Whoops wrong button!

0reactions
AlecAivaziscommented, Jun 13, 2021

@thormuller I think I have a working update to support query in a component outside of src/routes. Mind pulling down #95 and giving it a shot?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Page Definition Queries—Help | ArcGIS for Desktop
Page Definition Queries allow you to specify which features of a layer draw based on an SQL query. Though similar to other definition...
Read more >
Using feature queries - CSS: Cascading Style Sheets | MDN
Feature queries are created using the CSS at-rule @supports, and are useful as they give web developers a way to test to see...
Read more >
query or filter fields of page layouts. - Salesforce Developers
query or filter fields of page layouts. Hi, There are almost 500 fields in Accounts and Iam trying to delete the fields of...
Read more >
Guide to designing reports - Microsoft Support
In this article. Decide how to lay out your report. Use control layouts to align your data. Add or remove report or page...
Read more >
Finding out which page layouts are available for an object with ...
The Tooling API is your friend here. You can make a call to /services/data/v33.0/tooling/query/ and query the layouts per object.
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