I have the same problem in two different websites I'm building with Gatsby.
When I run gatsby develop, I sometimes get this error:
ERROR #85923 GRAPHQL.VALIDATION
There was an error in your GraphQL query:
Cannot query field "siteUrl" on type "SiteSiteMetadata".
If you don't expect "siteUrl" to exist on the type "SiteSiteMetadata" it is most
likely a typo. However, if you expect "siteUrl" to exist there are a couple of
solutions to common problems:
- If you added a new data source and/or changed something inside
gatsby-node/gatsby-config, please try a restart of your development server.
- You want to optionally use your field "siteUrl" and right now it is not used
anywhere.
It is recommended to explicitly type your GraphQL schema if you want to use
optional fields.
It is repeated for every element of siteMetadata that I am trying to query.
If I run gatsby develop again the error goes away, but it returns apparently arbitrarily.
If I do gatsby build the query sometimes works sometimes doesn't.
My query is:
query {
site {
siteMetadata {
title
description
twitterUsername
image
siteUrl
}
}
}
And in gatsby-config.ts I have:
siteMetadata: {
title: `Querying Experience for NIME`,
description: `A website for the workshop on querying experience at NIME 2023`,
twitterUsername: `#zayaseevee`,
image: `/musician.png`,
siteUrl: `https://qe4nime.github.io/`
},
I suspect this is a typescript thing and I am quite new to it, but didn't want to stick with or reverse to javascript. Maybe I should've.
I have tried rerunning gatsby develop after updating gatsby-config.ts but that doesn't seem to be the problem.
I have also tried the suggestion in the answer to this question, but the error remains.
Related
I created a database in Directus. I created a separate project for the site, where I will add data. Installed # directus / sdk.
image
But when importing, I get an error
Uncaught SyntaxError: Cannot use import statement outside a module
this is my code
import { Directus } from '#directus/sdk';
const directus = new Directus('https://api.example.com/');
await directus.auth.login({
email: 'admin#example.com',
password: 'pass',
});
const articles = await directus.items('articles').readMany();
console.log({
items: articles.data,
total: articles.meta.total_count,
});
How do I fix this error?
Is it correct to create a separate project for the site? Or could it be done in the same place as the database?
TLDR; The issue faced is does not appear to be an issue with Directus.
There are three different pieces of software/code that that you should be aware of.
Database.
Directus Install.
Your App.
These are three different things, make sure you're clear on the difference. The database will be stored in your database of choice, MySQL, Postgres etc... Directus only connects to this and it will remain should you decide to stop using Directus for any reason.
You will need to install Directus in one location. You will then need to write your application in another location, where you may use the SDK for easy Directus API usage within your app.
It is correct (as you asked) to have your application as a separate "project".
The reason you are getting the error Cannot use import statement outside a module is not related to Directus. This is a common error when you are building or compiling your application incorrectly (Not ES6) therefore I cannot provide much support to you.
Here are some helpful debugging resources:
https://www.google.com/search?q=cannot+use+import+statement+outside+a+module
"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6
https://exerror.com/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-importing-ecmascript-6/
I am following the ember tutorials, and specifically I'm on services.
I am 99.9% certain that I have the exact code in place -- I am copying by hand, because I believe that helps me absorb it more completely, but if anything fails I start using a diff checker to see if I made a typo. To my knowledge, no typos.
The App I have written performs identically to the screen shots in the tutorials, and the only error I get is a lint error for having a test that doesn't have an assert in it (yet).
Prior to this unit, all other tests have passed as well. But now I am getting failed tests that previously passed. They appear to all stem from the stubbed call to the map service failing. The first test that fails is integration/component/rental-listing-test.js:
hooks.beforeEach(function() {
this.rental = {
image: 'fake.png',
title: 'test-title',
owner: 'test-owner',
type: 'test-type',
city: 'test-city',
bedrooms: 3
};
});
test('should display rental details', async function(assert) {
await render(hbs`{{rental-listing rental=rental}}`);
assert.equal(this.element.querySelector('.listing h3').textContent.trim(), 'test-title', 'Title: test-title');
assert.equal(this.element.querySelector('.listing .owner').textContent.trim(), 'Owner: test-owner', 'Owner: test-owner');
});
If I remove the new line from rental-listing.hbs ( {{location-map location=rental.city}} ), thus preventing the map from being used, these tests once again pass (though the new tests for the component using the service have issues).
So either I am doing something wrong that I can't find, or else the fine folk at emberjs.com have not provided complete information in this tutorial. Do I need to somehow stub the map service? that appears in the .hbs file for the above test to pass? If so, why do you think they failed to mention this?
ETA assertion:
Ajax authorization failed # 273 ms
Source: Error: Ajax authorization failed
at new EmberError (http://localhost:7357/assets/vendor.js:13635:31)
at new AjaxError (http://localhost:7357/assets/vendor.js:116954:13)
at new UnauthorizedError (http://localhost:7357/assets/vendor.js:116968:13)
at Class._createCorrectError (http://localhost:7357/assets/vendor.js:117533:25)
at Class.handleResponse (http://localhost:7357/assets/vendor.js:117528:25)
at Object.jqXHR.done.fail (http://localhost:7357/assets/vendor.js:117380:41)
at fire (http://localhost:7357/assets/vendor.js:3609:31)
at Object.fireWith [as rejectWith] (http://localhost:7357/assets/vendor.js:3739:7)
at done (http://localhost:7357/assets/vendor.js:9648:14)
at XMLHttpRequest.<anonymous> (http://localhost:7357/assets/vendor.js:9889:9)
You shouldn't need the api key to run the tests. Have you tried the super rentals repo to see if it has the same issue? https://github.com/ember-learn/super-rentals
If it does have the same problem we'll probably need to PR a fix to the tutorial.
Update
I see that the integration test in question is missing a stub maps service definition. It is there in the rentals repo, but not mentioned in the guides tutorial. See https://github.com/ember-learn/super-rentals/blob/master/tests/integration/components/rental-listing-test.js for the code. I've added this info to an issue for updating the guides: https://github.com/ember-learn/guides-source/issues/347
So I finally had time to look at it. The problem is that this is set up for the external map service to use an environment variable for an API key. This is why it runs the app fine (I use KEY=value ember s to start the app) but the tests were not. Simply using KEY=value ember t -s causes these tests to pass. And I'm left with only linting issues.
For the record, this is the sort of thing that should be in the tutorial itself, and I'm not sure why I didn't think of it before.
I am trying to learn how to process payments with Square, and am trying to run their examples from GitHub to get a feel regarding how to structure the payments application. I built the node example from here: https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/node_payment using npm install and npm build to get the app up and running.
I am using "4532759734545858" for the card number, "123" for CVV, "0120" for expiration, and "94103" for the zip. I got the card number from here: https://docs.connect.squareup.com/articles/using-sandbox where it states that this is a good number to use for a Visa sandbox.
Also, I have updated the config.json with properties from my developer settings.
When trying to process a payment a get a DOM element that says "Card Declined" without further specifying the error. Is there something I can do to parse the error?
Based on the documentation at: https://docs.connect.squareup.com/articles/using-sandbox#generatingerrorstates it seems the amount_money field of the request is not being populated, but I am having trouble confirming.
Ideally I would like to get to a point where I can add a card as a hash value to my db and use it for recurring billing...
That "card declined" message is actually the error you get back from Square's APIs. You can play around with the error messaging in the app.js file and the `error.jade. Try error.catagory, code, detail.
Keep in mind that this is just a sample app, to show that you can use the APIs with node.js, you probably don't want to use this code in your production system.
I have a GraphQL server implemented in Java and a JavaScript client querying it. What I don't like is that the client has to just know the schema and can not get it from the server instead and dynamically build queries against it.
Now, I understand GraphiQL somehow does just that, but I'm guessing it's because its backend is also written in JavaScript so both the client and server can use it. My schema is defined in Java, but there might be a way to automatically generate a JavaScript representation that the client could use.
Does such a thing already exist?
Now, I understand GraphiQL somehow does just that, but I'm guessing it's because its backend is also written in JavaScript so both the client and server can use it.
Actually, (fortunately) this is not the case. It is written in Javascript, but it need not be to achieve this behavior.
I've got some great news for you...
Introspection!
One of the awesome things about GraphQL is that, in fact, the client doesn't have to know anything about the schema, because it can just query the server for it using introspection. In fact, GraphiQL will use this automatically if you don't provide a schema explicitly to automagically populate it.
From the Props section of the GraphiQL README:
schema: a GraphQLSchema instance or null if one is not to be used. If undefined is provided, GraphiQL will send an introspection query using the fetcher to produce a schema.
The official GraphQL Introspection docs will give you lot more information and sample queries. Their example of querying their Star Wars example schema:
{
__schema {
types {
name
}
}
}
This returns the names of all of the types. Introspection is part of the GraphQL spec, so every GraphQL server should be able to do it out of the box: you don't need to explicitly add any functionality.
It seems that the Chooser in App SDK 1.32, though the query should be generic enough to pull the correct items, is not able to find any. Here is the code, which, even with the recent changes, I would think would be able to pull the data fine.
piChooser = new rally.sdk.ui.Chooser({
type: 'PortfolioItem',
title: 'Choose a Portfolio Item',
fetch: 'FormattedID,Name',
query: 'PortfolioItemType.Name = "MRU"',
width: 500,
height: 500
}, rallyDataSource);
Unfortunately, this looks like a Defect, which interestingly does not appear related to the 9/1 code release, as I was able to reproduce this on a local instance of Rally running an earlier code base (2012.05.19). It looks like it is a general problem with rally.sdk.ui.Chooser for PortfolioItem artifacts - the Chooser fails to display them, even if you specify no query.
I've filed a Defect with Rally Development on this. You may wish to submit a Case to rallysupport#rallydev.com if you would like updates on the Defect.