Skip to content

๐Ÿ‡ Swagger ํ•˜๋‚˜๋กœ GraphQL ๊ด€๋ จ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๋Š” CLI์ž…๋‹ˆ๋‹ค.

License

Notifications You must be signed in to change notification settings

738/graphql-from-swagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

44 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

graphql-from-swagger

๐Ÿ‡ Swagger ํ•˜๋‚˜๋กœ GraphQL ๊ด€๋ จ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๋Š” CLI์ž…๋‹ˆ๋‹ค.

demo

๊ฐœ์š”

๊ฐ„๋‹จํ•œ ์„ค์ • ํŒŒ์ผ ํ•˜๋‚˜์™€ ๋ช…๋ น์–ด ํ•˜๋‚˜๋กœ 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
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

About

๐Ÿ‡ Swagger ํ•˜๋‚˜๋กœ GraphQL ๊ด€๋ จ ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•ด์ฃผ๋Š” CLI์ž…๋‹ˆ๋‹ค.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published