src: added skeleton
parent
706f11ac41
commit
9aa94a33ce
@ -0,0 +1,20 @@
|
||||
import { DataSource } from 'apollo-datasource';
|
||||
|
||||
/**
|
||||
* extended datasource to feed resolvers with data about cargoBikes
|
||||
*/
|
||||
export class CargoBikeAPI extends DataSource {
|
||||
constructor() {
|
||||
super();
|
||||
// this.store = store;
|
||||
}
|
||||
/**
|
||||
* Finds cargo bike by id
|
||||
*/
|
||||
async findCargoBikeById({ id }:{id: any}){
|
||||
return {
|
||||
id,
|
||||
name: "hello world"
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { DataSource} from 'apollo-datasource';
|
||||
|
||||
/**
|
||||
* fetches datafrom user server, especially validates user tokens
|
||||
*/
|
||||
export class UserServerAPI extends DataSource{
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* validates user token
|
||||
*/
|
||||
async validateToken(token:string){
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
export default {
|
||||
Query: {
|
||||
cargobike: () => {
|
||||
return {
|
||||
id:1,
|
||||
name: "hello!"
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,6 @@
|
||||
export default {
|
||||
Query: {
|
||||
cargobike: (_: any,{ id }:{id: any},{dataSources}:{dataSources: any}) =>
|
||||
dataSources.cargoBikeAPI.findCargoBikeById( { id } )
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue