No time? Learn by doing in the GraphQL Playground! 🚀
GraphQL wrapper for the wiewarm.ch RESTful API. Thanks to GraphQL just get the data you need or want.
- Learn the schema by playing with the data in the Playground.
- Have a look at the client implementations or choose a client implementation from the GraphQL clients implementations.
- Use the server url https://wiewarm-graphql.raphaelgosteli.now.sh/
- Let's go! 🤗
Search for a bad
Query {
search(query: "Thun"){
id
name
location
}
}
Get the name, temperature and the prettified date of a bad by it's id.
Query {
bad(id: 5) {
name
becken {
temp
datePretty
}
}
}
Get all bad and show their id, location and becken info.
Query {
bads {
id
location
becken {
status
type
}
}
}
Have a look at the Android example → by @wauchi using the Apollo Android client.
No time? Have a look at the example project. Angular example →
Add the apollo angular implementation to your angular project.
ng add apollo-angular
Change constant uri
in the src/app/graphql.module.ts
to
const uri = 'https://wiewarm-graphql.raphaelgosteli.now.sh'
Query the data using the Apollo Client method watchQuery
src/app.component.ts
apollo.watchQuery({
query: gql`
{
bads {
id
name
location
becken {
name
temp
}
}
}
`
}).valueChanges.subscribe(result => {
this.bads = result.data && result.data.bads;
this.loading = result.loading;
this.error = result.errors;
})
Load the data into a template by iterating through the list of bad as shown in the example.
src/app.component.html
<div *ngIf="bads">
<div *ngFor="let bad of bads">
<div class="bad">
<p class="bad-id">#{{bad.id}}</p>
<h2>{{bad.name}}</h2>
<p class="location">{{bad.location}}</p>
<table>
<tr>
<th>Becken</th>
<th>Temperatur</th>
</tr>
<tr *ngFor="let becken of bad.becken">
<td>{{becken.name}}</td>
<td>{{becken.temp}}°C</td>
</tr>
</table>
</div>
</div>
</div>
type Bad {
id: Int
name: String
address1: String
address2: String
canton: String
plz: String
location: String
long: Int
lat: Int
becken: [Becken]
}
type Becken {
id: Int
name: String
temp: String
status: String
typ: String
date: String
datePretty: String
}