Skip to content

Commit

Permalink
fix: reuse already existed types for graphql (eg AwsLightsailCreateCo…
Browse files Browse the repository at this point in the history
…ntainerServiceDeployment is defined twice in aws-sdk)
  • Loading branch information
nodkz committed Jun 23, 2021
1 parent 263da58 commit 785a6bd
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/fullApi/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import express from 'express';
import graphqlHTTP from 'express-graphql';
import { graphqlHTTP } from 'express-graphql';
import schema from './schema';

const expressPort = process.env.port || process.env.PORT || 4000;
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
},
"devDependencies": {
"@types/express": "4.17.12",
"@types/express-graphql": "^0.9.0",
"@types/jest": "26.0.23",
"@typescript-eslint/eslint-plugin": "4.25.0",
"@typescript-eslint/parser": "4.25.0",
"aws-sdk": "2.918.0",
"aws-sdk": "2.924.0",
"eslint": "7.27.0",
"eslint-config-airbnb-base": "14.2.1",
"eslint-config-prettier": "8.3.0",
Expand Down
11 changes: 10 additions & 1 deletion src/AwsParam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,17 @@ export class AwsParam {
});
}

const typename = `${name}Input`;

if (schemaComposer.has(typename)) {
console.warn(
`Type ${typename} already exists. It seems that aws-sdk has types with same names. Reusing already existed type for GraphQL schema.`
);
return schemaComposer.get(typename) as any;
}

const itc = schemaComposer.createInputTC({
name: `${name}Input`,
name: typename,
fields,
});

Expand Down
25 changes: 4 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,6 @@
dependencies:
"@types/node" "*"

"@types/express-graphql@^0.9.0":
version "0.9.0"
resolved "https://registry.yarnpkg.com/@types/express-graphql/-/express-graphql-0.9.0.tgz#6f891c11785204bff3a27cae00180c4228550eb8"
integrity sha512-+n13emasFUtIn5kpJUTIUy4tAiJBRnHSChpA8OVmKvdKYbzzK6iI/zsnWEKP8qQJDpiUh48wrRKIXNC+5U/t+w==
dependencies:
express-graphql "*"

"@types/express-serve-static-core@*":
version "4.17.9"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.9.tgz#2d7b34dcfd25ec663c25c85d76608f8b249667f1"
Expand Down Expand Up @@ -1705,10 +1698,10 @@ at-least-node@^1.0.0:
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==

aws-sdk@2.918.0:
version "2.918.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.918.0.tgz#e4323de000262beb762e9c139f89e07282462f17"
integrity sha512-ZjWanOA1Zo664EyWLCnbUlkwCjoRPmSIMx529W4gk1418qo3oCEcvUy1HeibGGIClYnZZ7J4FMQvVDm2+JtHLQ==
aws-sdk@2.924.0:
version "2.924.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.924.0.tgz#daefcd11729638d9c9279633a0cc5ba1c98fee64"
integrity sha512-EwJmZDNhEY1/hrihile8+EdrYrT5VKcLuL5F+OA9L+AYWxNou0i4fP36N5KFtMikkAGB31qhAuRDPcr132RnUw==
dependencies:
buffer "4.9.2"
events "1.1.1"
Expand Down Expand Up @@ -3359,16 +3352,6 @@ expect@^27.0.2:
jest-message-util "^27.0.2"
jest-regex-util "^27.0.1"

express-graphql@*:
version "0.11.0"
resolved "https://registry.yarnpkg.com/express-graphql/-/express-graphql-0.11.0.tgz#48089f0d40074d7783c65ff86dd9cae95afea2ef"
integrity sha512-IMYmF2aIBKKfo8c+EENBNR8FAy91QHboxfaHe1omCyb49GJXsToUgcjjIF/PfWJdzn0Ofp6JJvcsODQJrqpz2g==
dependencies:
accepts "^1.3.7"
content-type "^1.0.4"
http-errors "1.8.0"
raw-body "^2.4.1"

express-graphql@0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/express-graphql/-/express-graphql-0.12.0.tgz#58deabc309909ca2c9fe2f83f5fbe94429aa23df"
Expand Down

0 comments on commit 785a6bd

Please sign in to comment.