chore: Introduce GraphQLJSONObject type for credentials

This commit is contained in:
Faruk AYDIN
2021-10-24 16:51:29 +02:00
committed by Ali BARIN
parent c7d757a337
commit 2eeeeb0028
8 changed files with 12 additions and 29 deletions

View File

@@ -22,6 +22,7 @@
"express": "~4.16.1",
"express-graphql": "^0.12.0",
"flickr-sdk": "^3.10.0",
"graphql-type-json": "^0.3.2",
"http-errors": "~1.6.3",
"knex": "^0.95.11",
"morgan": "^1.10.0",

View File

@@ -2,8 +2,8 @@ import { GraphQLString, GraphQLNonNull } from 'graphql';
import Connection from '../../models/connection';
import App from '../../models/app';
import connectionType from '../types/connection';
import twitterCredentialInputType from '../types/twitter-credential-input';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
import { GraphQLJSONObject } from 'graphql-type-json';
type Params = {
key: string,
@@ -27,7 +27,7 @@ const createConnection = {
type: connectionType,
args: {
key: { type: GraphQLNonNull(GraphQLString) },
data: { type: GraphQLNonNull(twitterCredentialInputType) }
data: { type: GraphQLNonNull(GraphQLJSONObject) }
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createConnectionResolver(params, req)
};

View File

@@ -1,7 +1,7 @@
import { GraphQLString, GraphQLNonNull } from 'graphql';
import { GraphQLJSONObject } from 'graphql-type-json';
import Connection from '../../models/connection';
import connectionType from '../types/connection';
import twitterCredentialInputType from '../types/twitter-credential-input';
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
type Params = {
@@ -28,7 +28,7 @@ const updateConnection = {
type: connectionType,
args: {
id: { type: GraphQLNonNull(GraphQLString) },
data: { type: GraphQLNonNull(twitterCredentialInputType) }
data: { type: GraphQLNonNull(GraphQLJSONObject) }
},
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => updateConnectionResolver(params, req)
};

View File

@@ -1,12 +0,0 @@
import { GraphQLString, GraphQLInputObjectType } from 'graphql';
const twitterCredentialInputType = new GraphQLInputObjectType({
name: 'TwitterCredentialInput',
fields: {
consumerKey: { type: GraphQLString },
consumerSecret: { type: GraphQLString },
oauthVerifier: { type: GraphQLString },
}
})
export default twitterCredentialInputType;

View File

@@ -1,11 +0,0 @@
import { GraphQLString, GraphQLObjectType } from 'graphql';
const twitterCredentialInputType = new GraphQLObjectType({
name: 'TwitterCredential',
fields: {
consumerKey: { type: GraphQLString },
consumerSecret: { type: GraphQLString },
}
})
export default twitterCredentialInputType;

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const CREATE_CONNECTION = gql`
mutation CreateConnection($key: String!, $data: TwitterCredentialInput!) {
mutation CreateConnection($key: String!, $data: JSONObject!) {
createConnection(key: $key, data: $data) {
id
key

View File

@@ -1,7 +1,7 @@
import { gql } from '@apollo/client';
export const UPDATE_CONNECTION = gql`
mutation UpdateConnection($id: String!, $data: TwitterCredentialInput!) {
mutation UpdateConnection($id: String!, $data: JSONObject!) {
updateConnection(id: $id, data: $data) {
id
key

View File

@@ -7959,6 +7959,11 @@ graphql-tag@^2.12.3:
dependencies:
tslib "^2.1.0"
graphql-type-json@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/graphql-type-json/-/graphql-type-json-0.3.2.tgz#f53a851dbfe07bd1c8157d24150064baab41e115"
integrity sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==
graphql@^15.6.0:
version "15.6.1"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.6.1.tgz#9125bdf057553525da251e19e96dab3d3855ddfc"