chore: Use key instead of name as parameter for getApp query
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Twitch",
|
"name": "Twitch",
|
||||||
"key": "twitch",
|
"key": "twitch",
|
||||||
"slug": "twitch",
|
|
||||||
"iconUrl": "https://automatisch.io/apps/twitch.png",
|
"iconUrl": "https://automatisch.io/apps/twitch.png",
|
||||||
"docUrl": "https://automatisch.io/docs/twitch",
|
"docUrl": "https://automatisch.io/docs/twitch",
|
||||||
"primaryColor": "6441a5",
|
"primaryColor": "6441a5",
|
||||||
|
@@ -16,7 +16,7 @@ export default class Twitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.connectionData = connectionData;
|
this.connectionData = connectionData;
|
||||||
this.appData = App.findOneByName('twitter');
|
this.appData = App.findOneByKey('twitter');
|
||||||
}
|
}
|
||||||
|
|
||||||
async createAuthLink() {
|
async createAuthLink() {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "Twitter",
|
"name": "Twitter",
|
||||||
"key": "twitter",
|
"key": "twitter",
|
||||||
"slug": "twitter",
|
|
||||||
"iconUrl": "https://automatisch.io/apps/twitter.png",
|
"iconUrl": "https://automatisch.io/apps/twitter.png",
|
||||||
"docUrl": "https://automatisch.io/docs/twitter",
|
"docUrl": "https://automatisch.io/docs/twitter",
|
||||||
"primaryColor": "2DAAE1",
|
"primaryColor": "2DAAE1",
|
||||||
|
@@ -3,21 +3,21 @@ import App from '../../models/app';
|
|||||||
import appType from '../types/app';
|
import appType from '../types/app';
|
||||||
|
|
||||||
type Params = {
|
type Params = {
|
||||||
name: string
|
key: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAppResolver = (params: Params) => {
|
const getAppResolver = (params: Params) => {
|
||||||
if(!params.name) {
|
if(!params.key) {
|
||||||
throw new Error('No name provided.')
|
throw new Error('No key provided.')
|
||||||
}
|
}
|
||||||
|
|
||||||
return App.findOneByName(params.name)
|
return App.findOneByKey(params.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getApp = {
|
const getApp = {
|
||||||
type: appType,
|
type: appType,
|
||||||
args: {
|
args: {
|
||||||
name: { type: GraphQLNonNull(GraphQLString) },
|
key: { type: GraphQLNonNull(GraphQLString) },
|
||||||
},
|
},
|
||||||
resolve: (_: any, params: Params) => getAppResolver(params)
|
resolve: (_: any, params: Params) => getAppResolver(params)
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,6 @@ const appType = new GraphQLObjectType({
|
|||||||
name: { type: GraphQLString },
|
name: { type: GraphQLString },
|
||||||
key: { type: GraphQLString },
|
key: { type: GraphQLString },
|
||||||
connectionCount: { type: GraphQLInt },
|
connectionCount: { type: GraphQLInt },
|
||||||
slug: { type: GraphQLString },
|
|
||||||
iconUrl: { type: GraphQLString },
|
iconUrl: { type: GraphQLString },
|
||||||
docUrl: { type: GraphQLString },
|
docUrl: { type: GraphQLString },
|
||||||
primaryColor: { type: GraphQLString },
|
primaryColor: { type: GraphQLString },
|
||||||
|
@@ -16,6 +16,11 @@ class App {
|
|||||||
const rawAppData = fs.readFileSync(this.folderPath + `/${name}/info.json`, 'utf-8');
|
const rawAppData = fs.readFileSync(this.folderPath + `/${name}/info.json`, 'utf-8');
|
||||||
return JSON.parse(rawAppData);
|
return JSON.parse(rawAppData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static findOneByKey(key: string): object {
|
||||||
|
const rawAppData = fs.readFileSync(this.folderPath + `/${key}/info.json`, 'utf-8');
|
||||||
|
return JSON.parse(rawAppData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
Reference in New Issue
Block a user