feat: add app connections w/ testing and deleting functions

This commit is contained in:
Ali BARIN
2021-10-18 23:58:40 +02:00
parent 672cc4c60c
commit 2293c939e7
27 changed files with 349 additions and 34 deletions

View File

@@ -4,6 +4,31 @@ const cache = new InMemoryCache({
typePolicies: {
App: {
keyFields: ['key']
},
Mutation: {
mutationType: true,
fields: {
createConnection: {
merge(existing, newConnection, { args, readField, cache }) {
const appKey = readField('key', newConnection);
const appCacheId = cache.identify({
__typename: 'App',
key: appKey,
});
cache.modify({
id: appCacheId,
fields: {
connections: (existingConnections) => {
return [...existingConnections, newConnection];
}
}
});
return newConnection;
}
}
}
}
}
});

View File

@@ -3,8 +3,15 @@ import { gql } from '@apollo/client';
export const CREATE_CONNECTION = gql`
mutation CreateConnection($key: String!, $data: twitterCredentialInput!) {
createConnection(key: $key, data: $data) {
key
id
key
verified
data {
screenName
}
app {
key
}
}
}
`;

View File

@@ -0,0 +1,7 @@
import { gql } from '@apollo/client';
export const DELETE_CONNECTION = gql`
mutation DeleteConnection($id: String!) {
deleteConnection(id: $id)
}
`;

View File

@@ -1,6 +1,7 @@
import { CREATE_CONNECTION } from './create-connection';
import { CREATE_AUTH_LINK } from './create-auth-link';
import { UPDATE_CONNECTION } from './update-connection';
import { DELETE_CONNECTION } from './delete-connection';
import { CREATE_AUTH_LINK } from './create-auth-link';
type Mutations = {
[key: string]: any,
@@ -9,6 +10,7 @@ type Mutations = {
const mutations: Mutations = {
createConnection: CREATE_CONNECTION,
updateConnection: UPDATE_CONNECTION,
deleteConnection: DELETE_CONNECTION,
createAuthLink: CREATE_AUTH_LINK,
};

View File

@@ -6,6 +6,9 @@ export const UPDATE_CONNECTION = gql`
id
key
verified
data {
screenName
}
}
}
`;

View File

@@ -0,0 +1,17 @@
import { gql } from '@apollo/client';
export const GET_APP_CONNECTIONS = gql`
query GetAppConnections($key: String!) {
getApp(key: $key) {
key
connections {
id
key
verified
data {
screenName
}
}
}
}
`;

View File

@@ -32,6 +32,9 @@ export const GET_APP = gql`
}
}
}
connections {
id
}
}
}
`;

View File

@@ -19,6 +19,9 @@ export const GET_APPS = gql`
docUrl
clickToCopy
}
connections {
id
}
}
}
`;

View File

@@ -0,0 +1,7 @@
import { gql } from '@apollo/client';
export const TEST_CONNECTION = gql`
query TestConnection($id: String!) {
testConnection(id: $id)
}
`;