Add files via upload

Sample client
This commit is contained in:
Jaime Idolpx 2022-06-14 13:37:32 -05:00 committed by GitHub
parent 453e53bfef
commit f31dbc445a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 145 additions and 0 deletions

16
client/index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSDb Example GraphQL Client</title>
</head>
<body>
<h1>Loading...</h1>
<img src="" />
<script src="src/js/app.js"></script>
</body>
</html>

View File

129
client/src/js/app.js Normal file
View File

@ -0,0 +1,129 @@
const GRAPHQL_URL = 'http://localhost:3000/';
async function getRelease(id) {
const response = await fetch(GRAPHQL_URL, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify({
query: `
query {
getRelease(id: ${id}) {
ID
Name
AKA
Type
GfxType
Rating
ReleaseDate {
Operator
Day
Month
Year
Comment
}
ReleasedAt
Achievement {
Compo
Place
}
ReleasedBy {
GroupIDs
HandleIDs
}
Credits {
CreditType
HandleID
}
Website
ScreenShot
DownloadLinks {
CounterLink
Downloads
Filename
Link
Status
crc32
}
OtherLinks {
Title
Link
CounterLink
Clicks
}
Comments {
Summary {
Date
ScenerID
Text
}
Trivia {
Date
ScenerID
Text
}
Goofs {
Date
ScenerID
Text
}
HiddenPart {
Date
ScenerID
Text
}
ProductionNote {
Date
ScenerID
Text
}
UserComment {
Date
ScenerID
Text
}
}
SIDIDs
Groups {
ID
Name
}
Sceners {
ID
Country
}
Handles {
ID
Handle
}
Events {
ID
Name
Tagline
}
SIDs {
ID
Name
HVSCPath
}
Tags
}
}
`,
}),
});
const {
data
} = await response.json();
return data.getRelease;
}
getRelease(1).then((release) => {
const title = document.querySelector('h1');
title.textContent = release.Name;
const screenshot = document.querySelector('img');
screenshot.src = release.ScreenShot;
});