0.7.0 โข Published 4 years ago
graphql-from-swagger v0.7.0
graphql-from-swagger
๐ Swagger ํ๋๋ก GraphQL ๊ด๋ จ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ๋ CLI์ ๋๋ค.
๊ฐ์
๊ฐ๋จํ ์ค์ ํ์ผ ํ๋์ ๋ช ๋ น์ด ํ๋๋ก Swagger๋ฅผ ํตํด GraphQL ๊ด๋ จ ์ฝ๋๋ฅผ ์์ฑํด์ฃผ๋ CLI์ ๋๋ค.
Input
- Swagger
Output
- GraphQL Schema
- Schema Type Definition
- RESTDataSource(apollo-datasource-rest) Child Class
- GraphQL Resolvers
CLI Usage
$ npx graphql-from-swagger
ํน์
$ npm i -g graphql-from-swagger
$ graphql-from-swagger
Config
ํ๋ก์ ํธ ๋ฃจํธ ๋๋ ํ ๋ฆฌ์ graphql-from-swagger.config.json
ํ์ผ์ ์์ฑํฉ๋๋ค.
๋ค์์ ์์ ์ค์ ํ์ผ์ ๋๋ค.
{
"swaggerPaths": ["test/swagger.json", "https://petstore.swagger.io/v2/swagger.json"],
"schemaOutputFiles": ["generated/heroes.graphql", "generated/petstore.graphql"],
"typesOutputFiles": ["generated/HeroesTypes.ts", "generated/PetstoreTypes.ts"],
"restDataSourceOutputFiles": ["generated/HeroesApi.ts", "generated/PetstoreApi.ts"],
"resolversOutputFiles": ["generated/HeroesResolvers.ts", "generated/PetstoreResolvers.ts"]
}
์ค์ ์ ์ํ 5๊ฐ์ง ๋ณ์๊ฐ ์์ต๋๋ค.
field | type | description | ext | ||
---|---|---|---|---|---|
swaggerPaths | string[] | swagger.json ํน์ swagger.yaml ํ์ผ์ ๊ฒฝ๋ก ํน์ url์ ๋๋ค. | .json | .yaml | url |
schemaOutputFiles | string[] | swagger๋ฅผ ํตํด ์์ฑ๋ GraphQL Schema ํ์ผ์ ๊ฒฝ๋ก์ ๋๋ค. | .graphql | ||
typesOutputFiles | string[] | GraphQL Schema๋ฅผ ํตํด ์์ฑ๋ Type Definition ํ์ผ์ ๊ฒฝ๋ก์ ๋๋ค. | .ts | ||
restDataSourceOutputFiles | string[] | RESTDataSource(apollo-datasource-rest)์ ์์ํด๋์ค ํ์ผ์ ๊ฒฝ๋ก์ ๋๋ค. | .ts | ||
resolversOutputFiles | string[] | ์์ฑ๋ resolvers ํ์ผ์ ๊ฒฝ๋ก์ ๋๋ค. | .ts |
Dependencies
swagger
๋ฅผ ํตํด GraphQL Schema๋ฅผ ์์ฑํ ๋swagger-to-graphql
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค.- GraphQL Schema๋ฅผ ํตํด Typescript Type Definition ํ์ผ์ ์์ฑํ ๋
@graphql-codegen/typescript
๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
License
MIT