graphiql interface shows no results, but query returns valid response - aws-amplify

I googled a bit, but couldn't find anyone else complaining about this issue. I am using amplify mock to test GraphQL queries locally. Everything works as expected, mutations do insert data to Sqlite DB just fine, however query results do not show in GraphiQL UI. I checked the browser developer tools console for any errors, but none shown. The HTTP response does show the expected results. Tried in Chrome and Safari only to see same behavior. I am on MacOS Monterey. Any tips appreciated.
query MyQuery {
getBlog(id: "73545774-56dd-45d9-b34c-ada280cc7ef4") {
id
name
updatedAt
createdAt
}
}
The ID shown in the query above is a record that exists in Sqlite DB. it was inserted through a Mutation query. The browser tab does show the below correct response.
{
"data": {
"getBlog": {
"id": "73545774-56dd-45d9-b34c-ada280cc7ef4",
"name": "First Blog",
"updatedAt": "2022-07-27T17:55:02.052Z",
"createdAt": "2022-07-27T17:55:02.052Z"
}
}
}
However, the GraphiQL interface not render the results correctly. It does show some expand/collapse arrow icons. See attached screenshot:
Results pane in GraphiQL shows empty
Why would GraphiQL interface behave this way? Any suggestions?
This is my setup:
node -v
v16.13.0
npm -v
8.5.2
amplify -v
9.1.0
Google Chrome
103.0.5060.134 (Official Build) (x86_64)
npm create-react-app myapp
cd myapp
npm install #aws-amplify/cli -g
amplify init
amplify add api
DYNAMODB_ENDPOINT='http://localhost:62224' amplify mock
...
AppSync Mock endpoint is running at http://10.0.0.180:20002

Related

Cannot create an app that listens the webhook "pull_request_review_thread"

I am trying to create a simple app that will output the payload after the webhook "pull_request_review_thread" is triggered with any action. Here is the link to the related webhook: Pull_request_review_thread Github Docs
However, this code:
app.on("pull_request_review_thread", async(context) =>{ app.log.info(context.payload); })
gives the error:
Argument of type '"pull_request_review_thread"' is not assignable to parameter of type 'keyof EventTypesPayload | (keyof EventTypesPayload)[]'
Am I missing something?
The problem was not having the latest version of #octokit/webhooks-types. It can be checked with the command "npm ls #octokit/webhooks-types" , current latest version is 5.8.0

Next.js - Is it possible to debug getServerSideProps?

Hi as per docs getServerSideProps is a function which is executed only on server side.
export async function getServerSideProps(context) {
console.log("hello world");
debugger;
return {
props: {
age:55
}, // will be passed to the page component as props
}
}
As a consequence simply dropping a debugger keyword won't work.
I have tried:
Attaching the node.js debugger on port 9229
Running node --inspect-brk ./node_modules/next/dist/bin/next
Running cross-env NODE_OPTIONS='--inspect' next dev
But neither console.log() nor debugger keyword seem to have any effect.
However my props from getServerSideProps are passed in correctly, which proves the function is called.
Is it possible to stepthrough getServerSideProps or at least get console.log working? Thanks!
P.S.
The lines of code outside getServerSideProps are debuggable and work as expected.
In order to make the open the debug port open properly, you need to do the following:
// package.json scripts
"dev": "NODE_OPTIONS='--inspect' next dev"
// if you want custom debug port on a custom server
"dev": "NODE_OPTIONS='--inspect=5009' node server.js",
Once the debug port is own, you should be able to use inspector clients of your choice.
I had the same problem and I solved it with following steps. First, I installed cross-envpackage with
npm install cross-env
then I had to adjust my package.json with
"dev": "cross-env NODE_OPTIONS='--inspect' next dev",
After that you should be able to run npm run dev.
Open localhost:3000 or whatever port u are normally running nextjs app on. Open new tab and type
chrome://inspect
You should be able to see path to your app with word inspect at the end. After clicking new devTools will be opened with ability to set up breakpoints inside e.g. getStaticPaths, getStaticProps or getServerSideProps.

basic React Native SQLite script returning undefined which causes error

I'm trying to learn to use react-native-sqlite-storage as described on this page here:
https://github.com/andpor/react-native-sqlite-storage
I am working on a windows machine trying to build an android app. I have the following code:
import SQLite from 'react-native-sqlite-storage';
function errorCB(err) {
console.log("SQL Error: " + err);
}
function successCB() {
console.log("SQL executed fine");
}
function openCB() {
console.log("Database OPENED");
}
var db = SQLite.openDatabase("test.db", "1.0", "Test Database", 200000, openCB, errorCB);
db.transaction((tx) => {
tx.executeSql('SELECT * FROM Employees a, Departments b WHERE a.department = b.department_id', [], (tx, results) => {
console.log("Query completed");
});
});
export default 1;
When I run this, I get the error
undefined is not an object (evaluating
'NativeModules["SQLite"][method]')
The error is happening on the line var db = SQLite.openDatabase("test.db", "1.0", "Test Database", 200000, openCB, errorCB);
I suspect the reason the error is happening is because SQLite expects the existence of a database before you can actually open it. However, I do not see any instructions in the link above on how to create a database with react-native-sqlite-storage, so I'm not sure if my assumption is correct. Additionally, I assume I'd need to have a table for Employees, but again, the link above didn't explicitly state examples on how to create one. SO I don't know if my assumption is correct.
So how do I get SQLite.openDatabase() command to work?
More information
I deleted my project. Then I tried to re-install everything again, this time closely following the installation instructions for sqlite storage for android as mentioned on the andpor's github instructions (ie, modifying gradle files, updating MainApplication class etc...). Once I did that, running the command react-native run-android from the CLI causes this build error:
ERROR EPERM: operation not permitted, lstat 'C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar'
{"errno":-4048,"code":"EPERM","syscall":"lstat","path":"C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar"}
Error: EPERM: operation not permitted, lstat 'C:\Users\John
Lai\Projects\ReactNative\myapp\android\app\build\intermediates\exploded-aar\myapp\realm\unspecified\jars\classes.jar'
at Error (native)
I tried running this command as a regular user and as an administrator, and still the same issue.
More Information 2
I deleted my project. Then I did npm install for all my projects. Then I tried the commands rnpm link and react-native link react-native-sqlite-storage, both of which gave this error:
ERR! It seems something went wrong while linking. Error: spawn UNKNOWN
Please file an issue here: https://github.com/rnpm/rnpm/issues
So now the project won't even build. Any ideas?
the problem is the library is not linked
to link they suggest two ways
with pod (advanced)
with rnpm link (easy) but this command is deprecated
so to link the library you should use the
react-native link react-native-sqlite-storage
this command is equal to rnpm link but not deprecated
if automatic build failing try with manual linking for iOS manually linking ios and android manually linking android
lstat command error is generating on windows due to permission issues or npm version issues.
You can do 2 things to pass this.
1.Open terminal in admin mode .
2.upgrade/degrade npm version
For plugin installation, configure manually
You need change MainApplication.java with:
import org.pgsqlite.SQLitePluginPackage;
and
in getPackages:
new SQLitePluginPackage()

GraphiQL for Apollo Fine on Desktop, 404 on Laptop?

I've got GraphIQL running fine on my desktop Mac at http://localhost:8080/graphql.
And on my laptop Mac, using the exact same code synced via Github, I show this in the console:
GraphQL Server is now running on http://localhost:8080/graphql
...which appears to indicate that graphql is connected. But accessing
http://localhost:8080/graphql brings up a 404 error:
Not Found
The requested URL /graphql was not found on this server
I even deleted my node_modules folder and reinstalled from scratch via meteor npm install.
Does this make sense to anybody?
Here's the code that sets up Apollo and graphiql:
//apollo
import express from 'express';
import { apolloServer } from 'apollo-server';
import Schema from '/imports/api/schema';
import Mocks from '/imports/api/mocks';
import Resolvers from '/imports/api/resolvers';
import Connectors from '/imports/api/db-connectors';
const GRAPHQL_PORT = 8080;
const graphQLServer = express();
graphQLServer.use('/graphql', apolloServer({
graphiql: true,
schema: Schema,
resolvers: Resolvers,
connectors: Connectors,
mocks: Mocks,
}));
graphQLServer.listen(GRAPHQL_PORT, () => console.log(
`GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}/graphql`
));
So, this could be because you have something else running on 8080 on your laptop. Maybe try logging uncaught express errors to the console?
Another possibility is that you're not trying exactly the same URL on your desktop. Version 0.2 of apolloServer currently allows only POST requests. When you navigate to the address in your browser, it will try to send a GET request, which will result in a 404. Try spinning up graphiql on a separate route and see if you can access that.
PS: If you get a chance, you should make a PR to the repo where you copy-pasted the code snippet from, so other people won't run into the same issue ;-)
I used npm remove apollo-server and npm install apollo-server --save to update the apollo-server npm module, and did the same for apollo-client. I then updated to the apollo server 0.2.x code found at http://docs.apollostack.com/apollo-server/migration.html. I also updated to Meteor 1.4.x. Now the 404 error is gone.

retrieve artifact with maven timestamp from artifactory

Is there a way to retrieve an artifact with the maven timestamp as it was originally uploaded by maven?
from jenkins logs:
Uploading: http://artifactory.foo/artifactory/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-20160504.182015-2.tar.gz
Results from artifactory REST api:
$ curl -X GET 'http://artifactory.foo/artifactory/api/search/gavc?g=com.foo&a=foo-web-service&v=1.16.0-SNAPSHOT&c=*&repos=libs-snapshot-local'
{
"results" : [ {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT-sources.jar"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.pom"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.tar.gz"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.war"
} ]
}
I'd like to get the the same name as it was uploaded to via a wget or equivalent...
What I want to acheive:
jenkins uploads foo-web-service-1.16.0-20160504.182015-2.tar.gz to libs-snapshot-local
query REST api to get latest artifact link that includes the timestamps in the name with parameters a=foo-web-service&version=1.16.0&...
wget $artifact_link_with_timestamp
What I currently acheive that does not satisfy my need:
jenkins uploads foo-web-service-1.16.0-20160504.182015-2.tar.gz to libs-snapshot-local
query REST api via gavc search with parameters a=foo-web-service&version=1.16.0&...
wget $artifact_link
Conclusion as stated in the accepted answer, the problem was in the artifactory config itself. To achieve what I wanted, I needed the snapshots to be unique.
As long as your repository is configured to use unique snapshots (or to use client snapshot policy and you use Maven 3 and up), you can always use the Maven timestamp as a version. Replacing it with -SNAPSHOT is a "runtime" trick to make the resolution easier.
If your repository is configured to use non-unique snapshots, the files are actually stored with -SNAPSHOT instead of version and override previous snapshots (don't do that).

Resources