chore: Return connectionType for testConnection query

This commit is contained in:
Faruk AYDIN
2021-10-19 13:22:03 +02:00
committed by Ali BARIN
parent 650416ce6b
commit 5a2de1de9e
2 changed files with 13 additions and 4 deletions

View File

@@ -40,7 +40,11 @@ export default class Twitter {
} }
async isStillVerified() { async isStillVerified() {
const userData = await this.client.currentUser(); try {
return userData.id ? true : false await this.client.currentUser();
return true;
} catch (error) {
return false
}
} }
} }

View File

@@ -1,6 +1,7 @@
import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql'; import { GraphQLString, GraphQLNonNull, GraphQLBoolean } from 'graphql';
import Connection from '../../models/connection'; import Connection from '../../models/connection';
import RequestWithCurrentUser from '../../types/express/request-with-current-user'; import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import connectionType from '../types/connection'
type Params = { type Params = {
id: string, id: string,
@@ -17,11 +18,15 @@ const testConnectionResolver = async (params: Params, req: RequestWithCurrentUse
const appInstance = new appClass(connection.data) const appInstance = new appClass(connection.data)
const isStillVerified = await appInstance.isStillVerified(); const isStillVerified = await appInstance.isStillVerified();
return isStillVerified; connection = await connection.$query().patchAndFetch({
verified: isStillVerified
})
return connection;
} }
const testConnection = { const testConnection = {
type: GraphQLBoolean, type: connectionType,
args: { args: {
id: { type: GraphQLNonNull(GraphQLString) } id: { type: GraphQLNonNull(GraphQLString) }
}, },