项目作者: yamafaktory

项目描述 :
A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format
高级语言: Rust
项目地址: git://github.com/yamafaktory/craftql.git
创建时间: 2020-08-08T15:14:25Z
项目社区:https://github.com/yamafaktory/craftql

开源协议:MIT License

下载


CraftQL

GitHub Workflow Status Crates.io

A CLI tool to visualize GraphQL schemas and to output a graph data structure as a graphviz .dot format

Installation

  1. cargo install craftql

Usage

  1. USAGE:
  2. craftql [FLAGS] [OPTIONS] <path>
  3. ARGS:
  4. <path>
  5. Path to get files from
  6. FLAGS:
  7. -h, --help
  8. Prints help information
  9. -m, --missing-definitions
  10. Finds and displays missing definition(s)
  11. -O, --orphans
  12. Finds and displays orphan(s) node(s)
  13. -V, --version
  14. Prints version information
  15. OPTIONS:
  16. -f, --filter <filter>...
  17. Filter nodes by GraphQL type(s)
  18. - directive
  19. - enum
  20. - enum_extension
  21. - input_object
  22. - input_object_extension
  23. - interface
  24. - interface_extension
  25. - object
  26. - object_extension
  27. - scalar
  28. - scalar_extension
  29. - schema
  30. - union
  31. - union_extension
  32. -i, --incoming-dependencies <incoming-dependencies>
  33. Finds and displays incoming dependencies of a node
  34. -n, --node <node>
  35. Finds and displays one node
  36. -N, --nodes <nodes>...
  37. Finds and displays multiple nodes
  38. -o, --outgoing-dependencies <outgoing-dependencies>
  39. Finds and displays outgoing dependencies of a node

Output a graphviz .dot format

  1. craftql tests/fixtures
  2. digraph {
  3. 0 [ label = "DateTime (Scalar)" ]
  4. 1 [ label = "Character (Interface extension)\l\l[Boolean, Character]" ]
  5. 2 [ label = "Human (Object)\l\l[Character, Episode, Float, FriendsConnection, ID, Int, LengthUnit, Starship, String]" ]
  6. 3 [ label = "Droid (Object)\l\l[Character, Episode, FriendsConnection, ID, Int, String]" ]
  7. 4 [ label = "FriendsConnection (Object)\l\l[Character, FriendsEdge, Int, PageInfo]" ]
  8. 5 [ label = "FriendsEdge (Object)\l\l[Character, ID]" ]
  9. 6 [ label = "PageInfo (Object)\l\l[Boolean, ID, test]" ]
  10. 7 [ label = "Review (Object)\l\l[DateTime, Episode, Int, String, test]" ]
  11. 8 [ label = "Orphan (Object)\l\l[ID]" ]
  12. 9 [ label = "ColorInput (InputObject extension)\l\l[ColorInput, Int]" ]
  13. 10 [ label = "Episode (Enum extension)\l\l[Episode]" ]
  14. 11 [ label = "deprecated (Directive)\l\l[String]" ]
  15. 12 [ label = "DateTime (Scalar extension)\l\l[DateTime, test]" ]
  16. 13 [ label = "SearchResult (Union extension)\l\l[Ewok, SearchResult]" ]
  17. 14 [ label = "test (Directive)\l\l[Letter]" ]
  18. 15 [ label = "Episode (Enum)\l\l[deprecated, test]" ]
  19. 16 [ label = "LengthUnit (Enum)" ]
  20. 17 [ label = "Starship (Object extension)\l\l[Boolean, Starship]" ]
  21. 18 [ label = "Query (Object)\l\l[Character, Droid, Episode, Human, ID, Review, SearchResult, Starship, String]" ]
  22. 19 [ label = "Mutation (Object)\l\l[Episode, Review, ReviewInput]" ]
  23. 20 [ label = "Subscription (Object)\l\l[Episode, Review]" ]
  24. 21 [ label = "schema (Schema)\l\l[Mutation, Query, Subscription]" ]
  25. 22 [ label = "ReviewInput (InputObject)\l\l[ColorInput, Int, ReviewInput, String]" ]
  26. 23 [ label = "ColorInput (InputObject)\l\l[ColorInput, deprecated, Int, test]" ]
  27. 24 [ label = "Letter (Enum)" ]
  28. 25 [ label = "Starship (Object)\l\l[deprecated, Float, ID, LengthUnit, String]" ]
  29. 26 [ label = "Character (Interface)\l\l[Bool, Character, deprecated, Episode, FriendsConnection, ID, Int, String, test]" ]
  30. 27 [ label = "SearchResult (Union)\l\l[Droid, Human, Starship, test]" ]
  31. 13 -> 27 [ ]
  32. 14 -> 6 [ ]
  33. 26 -> 4 [ ]
  34. 5 -> 4 [ ]
  35. 6 -> 4 [ ]
  36. 11 -> 25 [ ]
  37. 16 -> 25 [ ]
  38. 26 -> 26 [ ]
  39. 11 -> 26 [ ]
  40. 15 -> 26 [ ]
  41. 4 -> 26 [ ]
  42. 14 -> 26 [ ]
  43. 26 -> 3 [ ]
  44. 15 -> 3 [ ]
  45. 4 -> 3 [ ]
  46. 17 -> 25 [ ]
  47. 15 -> 20 [ ]
  48. 7 -> 20 [ ]
  49. 19 -> 21 [ ]
  50. 18 -> 21 [ ]
  51. 20 -> 21 [ ]
  52. 9 -> 23 [ ]
  53. 26 -> 18 [ ]
  54. 3 -> 18 [ ]
  55. 15 -> 18 [ ]
  56. 2 -> 18 [ ]
  57. 7 -> 18 [ ]
  58. 27 -> 18 [ ]
  59. 25 -> 18 [ ]
  60. 26 -> 2 [ ]
  61. 15 -> 2 [ ]
  62. 4 -> 2 [ ]
  63. 16 -> 2 [ ]
  64. 25 -> 2 [ ]
  65. 1 -> 26 [ ]
  66. 15 -> 19 [ ]
  67. 7 -> 19 [ ]
  68. 22 -> 19 [ ]
  69. 23 -> 22 [ ]
  70. 22 -> 22 [ ]
  71. 23 -> 23 [ ]
  72. 11 -> 23 [ ]
  73. 14 -> 23 [ ]
  74. 24 -> 14 [ ]
  75. 12 -> 0 [ ]
  76. 12 -> 14 [ ]
  77. 11 -> 15 [ ]
  78. 14 -> 15 [ ]
  79. 10 -> 15 [ ]
  80. 0 -> 7 [ ]
  81. 15 -> 7 [ ]
  82. 14 -> 7 [ ]
  83. 26 -> 5 [ ]
  84. 3 -> 27 [ ]
  85. 2 -> 27 [ ]
  86. 25 -> 27 [ ]
  87. 14 -> 27 [ ]
  88. }

graph

Filter nodes by GraphQL types(s)

  1. craftql tests/fixtures --filter object object_extension
  2. digraph {
  3. 0 [ label = "Orphan (Object)\l\l[ID]" ]
  4. 1 [ label = "Human (Object)\l\l[Character, Episode, Float, FriendsConnection, ID, Int, LengthUnit, Starship, String]" ]
  5. 2 [ label = "Droid (Object)\l\l[Character, Episode, FriendsConnection, ID, Int, String]" ]
  6. 3 [ label = "FriendsConnection (Object)\l\l[Character, FriendsEdge, Int, PageInfo]" ]
  7. 4 [ label = "FriendsEdge (Object)\l\l[Character, ID]" ]
  8. 5 [ label = "PageInfo (Object)\l\l[@test, Boolean, ID]" ]
  9. 6 [ label = "Review (Object)\l\l[@test, DateTime, Episode, Int, String]" ]
  10. 7 [ label = "Query (Object)\l\l[Character, Droid, Episode, Human, ID, Review, SearchResult, Starship, String]" ]
  11. 8 [ label = "Mutation (Object)\l\l[Episode, Review, ReviewInput]" ]
  12. 9 [ label = "Subscription (Object)\l\l[Episode, Review]" ]
  13. 10 [ label = "Starship (Object extension)\l\l[Boolean, Starship]" ]
  14. 11 [ label = "Starship (Object)\l\l[@deprecated, Float, ID, LengthUnit, String]" ]
  15. 4 -> 3 [ ]
  16. 5 -> 3 [ ]
  17. 10 -> 11 [ ]
  18. 2 -> 7 [ ]
  19. 1 -> 7 [ ]
  20. 6 -> 7 [ ]
  21. 11 -> 7 [ ]
  22. 6 -> 9 [ ]
  23. 3 -> 2 [ ]
  24. 6 -> 8 [ ]
  25. 3 -> 1 [ ]
  26. 11 -> 1 [ ]
  27. }

Find and display one node

  1. craftql tests/fixtures --node Character
  2. # tests/fixtures/Types/Interfaces/Character.graphql
  3. interface Character @test {
  4. id: ID!
  5. name: String!
  6. friends: [Character]
  7. friendsConnection(first: Int, after: ID): FriendsConnection!
  8. appearsIn: [Episode]!
  9. cute: Bool! @deprecated
  10. }

Find and display multiple nodes

  1. craftql tests/fixtures --nodes Character Episode
  2. # tests/fixtures/Types/Interfaces/Character.graphql
  3. interface Character @test {
  4. id: ID!
  5. name: String!
  6. friends: [Character]
  7. friendsConnection(first: Int, after: ID): FriendsConnection!
  8. appearsIn: [Episode]!
  9. cute: Bool! @deprecated
  10. }
  11. # tests/fixtures/Types/Enums/Episode.gql
  12. enum Episode @test(letter: B) {
  13. NEWHOPE @deprecated
  14. EMPIRE
  15. JEDI
  16. }

Find and display orphan(s) node(s)

  1. craftql tests/fixtures --orphans
  2. # tests/fixtures/Types/Types/orphan.gql
  3. type Orphan {
  4. id: ID!
  5. }

Find and display incoming dependencies of a node

  1. craftql tests/fixtures --incoming-dependencies Starship
  2. # tests/fixtures/Types/Types/extension.graphql
  3. extend type Starship {
  4. antiGravity: Boolean!
  5. }
  6. # tests/fixtures/Types/Enums/LengthUnit.graphql
  7. enum LengthUnit {
  8. METER
  9. FOOT
  10. }
  11. # tests/fixtures/Directives/deprecated.graphql
  12. directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE

Find and display outgoing dependencies of a node

  1. craftql tests/fixtures --outgoing-dependencies Starship
  2. # tests/fixtures/Types/Types/b.graphql
  3. type Human implements Character {
  4. id: ID!
  5. name: String!
  6. homePlanet: String
  7. height(unit: LengthUnit = METER): Float
  8. mass: Float
  9. friends: [Character]
  10. friendsConnection(first: Int, after: ID): FriendsConnection!
  11. appearsIn: [Episode]!
  12. starships: [Starship]
  13. }
  14. # tests/fixtures/Types/Unions/SearchResults.graphql
  15. union SearchResult @test = Human | Droid | Starship
  16. # tests/fixtures/Types/Types/a.gql
  17. type Query {
  18. hero(episode: Episode): Character
  19. reviews(episode: Episode!): [Review]
  20. search(text: String): [SearchResult]
  21. character(id: ID!): Character
  22. droid(id: ID!): Droid
  23. human(id: ID!): Human
  24. starship(id: ID!): Starship
  25. }

Find and display missing definition(s)

  1. craftql tests/fixtures --orphans
  2. # Color is not defined in:
  3. # tests/fixtures/Types/Interfaces/Character.graphql
  4. interface Character @test {
  5. id: ID!
  6. name: String!
  7. friends: [Character]
  8. friendsConnection(first: Int, after: ID): FriendsConnection!
  9. appearsIn: [Episode]!
  10. cute: Boolean! @deprecated
  11. preferedColor: Color
  12. }
  13. # Ewok, Gungan are not defined in:
  14. # tests/fixtures/Types/Unions/SearchResultExtension.graphql
  15. extend union SearchResult = Ewok | Gungan