feat: Implement getAll and getAllByName graphQL queries
This commit is contained in:
40
packages/backend/src/apps/twitch/info.json
Normal file
40
packages/backend/src/apps/twitch/info.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "Twitch",
|
||||||
|
"iconUrl": "https://automatisch.io/apps/twitch.png",
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitch",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"key": "oAuthRedirectUrl",
|
||||||
|
"label": "OAuth Redirect URL",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": true,
|
||||||
|
"placeholder": "http://localhost:3000/sample",
|
||||||
|
"description": "When asked to input an OAuth callback or redirect URL in Twitch OAuth, enter the URL above.",
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitch#oauth-redirect-url",
|
||||||
|
"clickToCopy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "consumerKey",
|
||||||
|
"label": "Consumer Key",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": false,
|
||||||
|
"placeholder": null,
|
||||||
|
"description": null,
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitch#consumer-key",
|
||||||
|
"clickToCopy": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "consumerSecret",
|
||||||
|
"label": "Consumer Secret",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": false,
|
||||||
|
"placeholder": null,
|
||||||
|
"description": null,
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitch#consumer-secret",
|
||||||
|
"clickToCopy": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
40
packages/backend/src/apps/twitter/info.json
Normal file
40
packages/backend/src/apps/twitter/info.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "Twitter",
|
||||||
|
"iconUrl": "https://automatisch.io/apps/twitter.png",
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitter",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"key": "oAuthRedirectUrl",
|
||||||
|
"label": "OAuth Redirect URL",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": true,
|
||||||
|
"placeholder": "http://localhost:3000/sample",
|
||||||
|
"description": "When asked to input an OAuth callback or redirect URL in Twitter OAuth, enter the URL above.",
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitter#oauth-redirect-url",
|
||||||
|
"clickToCopy": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "consumerKey",
|
||||||
|
"label": "Consumer Key",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": false,
|
||||||
|
"placeholder": null,
|
||||||
|
"description": null,
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitter#consumer-key",
|
||||||
|
"clickToCopy": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "consumerSecret",
|
||||||
|
"label": "Consumer Secret",
|
||||||
|
"type": "string",
|
||||||
|
"required": true,
|
||||||
|
"readOnly": false,
|
||||||
|
"placeholder": null,
|
||||||
|
"description": null,
|
||||||
|
"docUrl": "https://automatisch.io/docs/twitter#consumer-secret",
|
||||||
|
"clickToCopy": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@@ -2,7 +2,8 @@ import { buildSchema } from 'graphql';
|
|||||||
|
|
||||||
const graphQLSchema = buildSchema(`
|
const graphQLSchema = buildSchema(`
|
||||||
type Query {
|
type Query {
|
||||||
hello: String
|
getApps: [String!]
|
||||||
|
getAppsByName(name: String!): [String!]
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
11
packages/backend/src/graphql/queries/get-apps-by-name.ts
Normal file
11
packages/backend/src/graphql/queries/get-apps-by-name.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import App from '../../models/app';
|
||||||
|
|
||||||
|
type Params = {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const getAppsByName = (params: Params) => {
|
||||||
|
return App.findAllByName(params.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getAppsByName;
|
7
packages/backend/src/graphql/queries/get-apps.ts
Normal file
7
packages/backend/src/graphql/queries/get-apps.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import App from '../../models/app';
|
||||||
|
|
||||||
|
const getApps = () => {
|
||||||
|
return App.findAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default getApps;
|
@@ -1,7 +1,9 @@
|
|||||||
|
import getApps from './queries/get-apps';
|
||||||
|
import getAppsByName from './queries/get-apps-by-name';
|
||||||
|
|
||||||
const rootResolver = {
|
const rootResolver = {
|
||||||
hello: () => {
|
getApps: getApps,
|
||||||
return 'Hello world!';
|
getAppsByName: getAppsByName
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default rootResolver;
|
export default rootResolver;
|
||||||
|
16
packages/backend/src/models/app.ts
Normal file
16
packages/backend/src/models/app.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
class App {
|
||||||
|
static folderPath = __dirname + '/../apps'
|
||||||
|
static list = fs.readdirSync(this.folderPath);
|
||||||
|
|
||||||
|
static findAll(): string[] {
|
||||||
|
return this.list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static findAllByName(name: string): string[] {
|
||||||
|
return this.list.filter((app) => app.includes(name.toLowerCase()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App;
|
Reference in New Issue
Block a user