feat: add app connections w/ testing and deleting functions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
7
packages/web/src/graphql/mutations/delete-connection.ts
Normal file
7
packages/web/src/graphql/mutations/delete-connection.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const DELETE_CONNECTION = gql`
|
||||
mutation DeleteConnection($id: String!) {
|
||||
deleteConnection(id: $id)
|
||||
}
|
||||
`;
|
@@ -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,
|
||||
};
|
||||
|
||||
|
@@ -6,6 +6,9 @@ export const UPDATE_CONNECTION = gql`
|
||||
id
|
||||
key
|
||||
verified
|
||||
data {
|
||||
screenName
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
17
packages/web/src/graphql/queries/get-app-connections.ts
Normal file
17
packages/web/src/graphql/queries/get-app-connections.ts
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
@@ -32,6 +32,9 @@ export const GET_APP = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
connections {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
@@ -19,6 +19,9 @@ export const GET_APPS = gql`
|
||||
docUrl
|
||||
clickToCopy
|
||||
}
|
||||
connections {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
7
packages/web/src/graphql/queries/test-connection.ts
Normal file
7
packages/web/src/graphql/queries/test-connection.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { gql } from '@apollo/client';
|
||||
|
||||
export const TEST_CONNECTION = gql`
|
||||
query TestConnection($id: String!) {
|
||||
testConnection(id: $id)
|
||||
}
|
||||
`;
|
Reference in New Issue
Block a user