introspection.lua 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. local parse = require 'graphql.parse'
  2. local validate = require 'graphql.validate'
  3. local execute = require 'graphql.execute'
  4. local util = require 'graphql.util'
  5. local cjson = require 'cjson'
  6. local schema = require 'tests/data/todo'
  7. local introspection_query = [[
  8. query IntrospectionQuery {
  9. __schema {
  10. queryType { name }
  11. mutationType { name }
  12. types {
  13. ...FullType
  14. }
  15. directives {
  16. name
  17. description
  18. locations
  19. args {
  20. ...InputValue
  21. }
  22. }
  23. }
  24. }
  25. fragment FullType on __Type {
  26. kind
  27. name
  28. description
  29. fields(includeDeprecated: true) {
  30. name
  31. description
  32. args {
  33. ...InputValue
  34. }
  35. type {
  36. ...TypeRef
  37. }
  38. isDeprecated
  39. deprecationReason
  40. }
  41. inputFields {
  42. ...InputValue
  43. }
  44. interfaces {
  45. ...TypeRef
  46. }
  47. enumValues(includeDeprecated: true) {
  48. name
  49. description
  50. isDeprecated
  51. deprecationReason
  52. }
  53. possibleTypes {
  54. ...TypeRef
  55. }
  56. }
  57. fragment InputValue on __InputValue {
  58. name
  59. description
  60. type { ...TypeRef }
  61. defaultValue
  62. }
  63. fragment TypeRef on __Type {
  64. kind
  65. name
  66. ofType {
  67. kind
  68. name
  69. ofType {
  70. kind
  71. name
  72. ofType {
  73. kind
  74. name
  75. ofType {
  76. kind
  77. name
  78. ofType {
  79. kind
  80. name
  81. ofType {
  82. kind
  83. name
  84. ofType {
  85. kind
  86. name
  87. }
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. ]]
  96. local introspection_expected_json = [[
  97. {
  98. "__schema": {
  99. "directives": [
  100. {
  101. "args": [
  102. {
  103. "defaultValue": null,
  104. "description": "Included when true.",
  105. "name": "if",
  106. "type": {
  107. "kind": "NON_NULL",
  108. "name": null,
  109. "ofType": {
  110. "kind": "SCALAR",
  111. "name": "Boolean",
  112. "ofType": null
  113. }
  114. }
  115. }
  116. ],
  117. "description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
  118. "locations": [
  119. "FIELD",
  120. "FRAGMENT_SPREAD",
  121. "INLINE_FRAGMENT"
  122. ],
  123. "name": "include"
  124. },
  125. {
  126. "args": [
  127. {
  128. "defaultValue": null,
  129. "description": "Skipped when true.",
  130. "name": "if",
  131. "type": {
  132. "kind": "NON_NULL",
  133. "name": null,
  134. "ofType": {
  135. "kind": "SCALAR",
  136. "name": "Boolean",
  137. "ofType": null
  138. }
  139. }
  140. }
  141. ],
  142. "description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
  143. "locations": [
  144. "FIELD",
  145. "FRAGMENT_SPREAD",
  146. "INLINE_FRAGMENT"
  147. ],
  148. "name": "skip"
  149. }
  150. ],
  151. "mutationType": null,
  152. "queryType": {
  153. "name": "Query"
  154. },
  155. "types": [
  156. {
  157. "description": null,
  158. "enumValues": null,
  159. "fields": [
  160. {
  161. "args": [
  162. {
  163. "defaultValue": null,
  164. "description": "id of the client",
  165. "name": "id",
  166. "type": {
  167. "kind": "NON_NULL",
  168. "name": null,
  169. "ofType": {
  170. "kind": "SCALAR",
  171. "name": "Int",
  172. "ofType": null
  173. }
  174. }
  175. }
  176. ],
  177. "deprecationReason": null,
  178. "description": null,
  179. "isDeprecated": false,
  180. "name": "client",
  181. "type": {
  182. "kind": "OBJECT",
  183. "name": "Client",
  184. "ofType": null
  185. }
  186. },
  187. {
  188. "args": [
  189. {
  190. "defaultValue": null,
  191. "description": "id of the project",
  192. "name": "id",
  193. "type": {
  194. "kind": "NON_NULL",
  195. "name": null,
  196. "ofType": {
  197. "kind": "SCALAR",
  198. "name": "Int",
  199. "ofType": null
  200. }
  201. }
  202. }
  203. ],
  204. "deprecationReason": null,
  205. "description": null,
  206. "isDeprecated": false,
  207. "name": "project",
  208. "type": {
  209. "kind": "OBJECT",
  210. "name": "Project",
  211. "ofType": null
  212. }
  213. },
  214. {
  215. "args": [
  216. {
  217. "defaultValue": null,
  218. "description": "id of the task",
  219. "name": "id",
  220. "type": {
  221. "kind": "NON_NULL",
  222. "name": null,
  223. "ofType": {
  224. "kind": "SCALAR",
  225. "name": "Int",
  226. "ofType": null
  227. }
  228. }
  229. }
  230. ],
  231. "deprecationReason": null,
  232. "description": null,
  233. "isDeprecated": false,
  234. "name": "task",
  235. "type": {
  236. "kind": "OBJECT",
  237. "name": "Task",
  238. "ofType": null
  239. }
  240. }
  241. ],
  242. "inputFields": null,
  243. "interfaces": [],
  244. "kind": "OBJECT",
  245. "name": "Query",
  246. "possibleTypes": null
  247. },
  248. {
  249. "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ",
  250. "enumValues": null,
  251. "fields": null,
  252. "inputFields": null,
  253. "interfaces": null,
  254. "kind": "SCALAR",
  255. "name": "Int",
  256. "possibleTypes": null
  257. },
  258. {
  259. "description": "Client",
  260. "enumValues": null,
  261. "fields": [
  262. {
  263. "args": [],
  264. "deprecationReason": null,
  265. "description": "The id of the client.",
  266. "isDeprecated": false,
  267. "name": "id",
  268. "type": {
  269. "kind": "NON_NULL",
  270. "name": null,
  271. "ofType": {
  272. "kind": "SCALAR",
  273. "name": "Int",
  274. "ofType": null
  275. }
  276. }
  277. },
  278. {
  279. "args": [],
  280. "deprecationReason": null,
  281. "description": "The name of the client.",
  282. "isDeprecated": false,
  283. "name": "name",
  284. "type": {
  285. "kind": "SCALAR",
  286. "name": "String",
  287. "ofType": null
  288. }
  289. },
  290. {
  291. "args": [],
  292. "deprecationReason": null,
  293. "description": "projects",
  294. "isDeprecated": false,
  295. "name": "projects",
  296. "type": {
  297. "kind": "LIST",
  298. "name": null,
  299. "ofType": {
  300. "kind": "OBJECT",
  301. "name": "Project",
  302. "ofType": null
  303. }
  304. }
  305. }
  306. ],
  307. "inputFields": null,
  308. "interfaces": [],
  309. "kind": "OBJECT",
  310. "name": "Client",
  311. "possibleTypes": null
  312. },
  313. {
  314. "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
  315. "enumValues": null,
  316. "fields": null,
  317. "inputFields": null,
  318. "interfaces": null,
  319. "kind": "SCALAR",
  320. "name": "String",
  321. "possibleTypes": null
  322. },
  323. {
  324. "description": "Project",
  325. "enumValues": null,
  326. "fields": [
  327. {
  328. "args": [],
  329. "deprecationReason": null,
  330. "description": "The id of the project.",
  331. "isDeprecated": false,
  332. "name": "id",
  333. "type": {
  334. "kind": "NON_NULL",
  335. "name": null,
  336. "ofType": {
  337. "kind": "SCALAR",
  338. "name": "Int",
  339. "ofType": null
  340. }
  341. }
  342. },
  343. {
  344. "args": [],
  345. "deprecationReason": null,
  346. "description": "The name of the project.",
  347. "isDeprecated": false,
  348. "name": "name",
  349. "type": {
  350. "kind": "SCALAR",
  351. "name": "String",
  352. "ofType": null
  353. }
  354. },
  355. {
  356. "args": [],
  357. "deprecationReason": null,
  358. "description": "client id",
  359. "isDeprecated": false,
  360. "name": "client_id",
  361. "type": {
  362. "kind": "NON_NULL",
  363. "name": null,
  364. "ofType": {
  365. "kind": "SCALAR",
  366. "name": "Int",
  367. "ofType": null
  368. }
  369. }
  370. },
  371. {
  372. "args": [],
  373. "deprecationReason": null,
  374. "description": "client",
  375. "isDeprecated": false,
  376. "name": "client",
  377. "type": {
  378. "kind": "OBJECT",
  379. "name": "Client",
  380. "ofType": null
  381. }
  382. },
  383. {
  384. "args": [],
  385. "deprecationReason": null,
  386. "description": "tasks",
  387. "isDeprecated": false,
  388. "name": "tasks",
  389. "type": {
  390. "kind": "LIST",
  391. "name": null,
  392. "ofType": {
  393. "kind": "OBJECT",
  394. "name": "Task",
  395. "ofType": null
  396. }
  397. }
  398. }
  399. ],
  400. "inputFields": null,
  401. "interfaces": [],
  402. "kind": "OBJECT",
  403. "name": "Project",
  404. "possibleTypes": null
  405. },
  406. {
  407. "description": "Task",
  408. "enumValues": null,
  409. "fields": [
  410. {
  411. "args": [],
  412. "deprecationReason": null,
  413. "description": "The id of the task.",
  414. "isDeprecated": false,
  415. "name": "id",
  416. "type": {
  417. "kind": "NON_NULL",
  418. "name": null,
  419. "ofType": {
  420. "kind": "SCALAR",
  421. "name": "Int",
  422. "ofType": null
  423. }
  424. }
  425. },
  426. {
  427. "args": [],
  428. "deprecationReason": null,
  429. "description": "The name of the task.",
  430. "isDeprecated": false,
  431. "name": "name",
  432. "type": {
  433. "kind": "SCALAR",
  434. "name": "String",
  435. "ofType": null
  436. }
  437. },
  438. {
  439. "args": [],
  440. "deprecationReason": null,
  441. "description": "project id",
  442. "isDeprecated": false,
  443. "name": "project_id",
  444. "type": {
  445. "kind": "NON_NULL",
  446. "name": null,
  447. "ofType": {
  448. "kind": "SCALAR",
  449. "name": "Int",
  450. "ofType": null
  451. }
  452. }
  453. },
  454. {
  455. "args": [],
  456. "deprecationReason": null,
  457. "description": "project",
  458. "isDeprecated": false,
  459. "name": "project",
  460. "type": {
  461. "kind": "OBJECT",
  462. "name": "Project",
  463. "ofType": null
  464. }
  465. }
  466. ],
  467. "inputFields": null,
  468. "interfaces": [],
  469. "kind": "OBJECT",
  470. "name": "Task",
  471. "possibleTypes": null
  472. },
  473. {
  474. "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query and mutation operations.",
  475. "enumValues": null,
  476. "fields": [
  477. {
  478. "args": [],
  479. "deprecationReason": null,
  480. "description": "A list of all types supported by this server.",
  481. "isDeprecated": false,
  482. "name": "types",
  483. "type": {
  484. "kind": "NON_NULL",
  485. "name": null,
  486. "ofType": {
  487. "kind": "LIST",
  488. "name": null,
  489. "ofType": {
  490. "kind": "NON_NULL",
  491. "name": null,
  492. "ofType": {
  493. "kind": "OBJECT",
  494. "name": "__Type",
  495. "ofType": null
  496. }
  497. }
  498. }
  499. }
  500. },
  501. {
  502. "args": [],
  503. "deprecationReason": null,
  504. "description": "The type that query operations will be rooted at.",
  505. "isDeprecated": false,
  506. "name": "queryType",
  507. "type": {
  508. "kind": "NON_NULL",
  509. "name": null,
  510. "ofType": {
  511. "kind": "OBJECT",
  512. "name": "__Type",
  513. "ofType": null
  514. }
  515. }
  516. },
  517. {
  518. "args": [],
  519. "deprecationReason": null,
  520. "description": "If this server supports mutation, the type that mutation operations will be rooted at.",
  521. "isDeprecated": false,
  522. "name": "mutationType",
  523. "type": {
  524. "kind": "OBJECT",
  525. "name": "__Type",
  526. "ofType": null
  527. }
  528. }
  529. },
  530. {
  531. "args": [],
  532. "deprecationReason": null,
  533. "description": "A list of all directives supported by this server.",
  534. "isDeprecated": false,
  535. "name": "directives",
  536. "type": {
  537. "kind": "NON_NULL",
  538. "name": null,
  539. "ofType": {
  540. "kind": "LIST",
  541. "name": null,
  542. "ofType": {
  543. "kind": "NON_NULL",
  544. "name": null,
  545. "ofType": {
  546. "kind": "OBJECT",
  547. "name": "__Directive",
  548. "ofType": null
  549. }
  550. }
  551. }
  552. }
  553. }
  554. ],
  555. "inputFields": null,
  556. "interfaces": [],
  557. "kind": "OBJECT",
  558. "name": "__Schema",
  559. "possibleTypes": null
  560. },
  561. {
  562. "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",
  563. "enumValues": null,
  564. "fields": [
  565. {
  566. "args": [],
  567. "deprecationReason": null,
  568. "description": null,
  569. "isDeprecated": false,
  570. "name": "kind",
  571. "type": {
  572. "kind": "NON_NULL",
  573. "name": null,
  574. "ofType": {
  575. "kind": "ENUM",
  576. "name": "__TypeKind",
  577. "ofType": null
  578. }
  579. }
  580. },
  581. {
  582. "args": [],
  583. "deprecationReason": null,
  584. "description": null,
  585. "isDeprecated": false,
  586. "name": "name",
  587. "type": {
  588. "kind": "SCALAR",
  589. "name": "String",
  590. "ofType": null
  591. }
  592. },
  593. {
  594. "args": [],
  595. "deprecationReason": null,
  596. "description": null,
  597. "isDeprecated": false,
  598. "name": "description",
  599. "type": {
  600. "kind": "SCALAR",
  601. "name": "String",
  602. "ofType": null
  603. }
  604. },
  605. {
  606. "args": [
  607. {
  608. "defaultValue": "false",
  609. "description": null,
  610. "name": "includeDeprecated",
  611. "type": {
  612. "kind": "SCALAR",
  613. "name": "Boolean",
  614. "ofType": null
  615. }
  616. }
  617. ],
  618. "deprecationReason": null,
  619. "description": null,
  620. "isDeprecated": false,
  621. "name": "fields",
  622. "type": {
  623. "kind": "LIST",
  624. "name": null,
  625. "ofType": {
  626. "kind": "NON_NULL",
  627. "name": null,
  628. "ofType": {
  629. "kind": "OBJECT",
  630. "name": "__Field",
  631. "ofType": null
  632. }
  633. }
  634. }
  635. },
  636. {
  637. "args": [],
  638. "deprecationReason": null,
  639. "description": null,
  640. "isDeprecated": false,
  641. "name": "interfaces",
  642. "type": {
  643. "kind": "LIST",
  644. "name": null,
  645. "ofType": {
  646. "kind": "NON_NULL",
  647. "name": null,
  648. "ofType": {
  649. "kind": "OBJECT",
  650. "name": "__Type",
  651. "ofType": null
  652. }
  653. }
  654. }
  655. },
  656. {
  657. "args": [],
  658. "deprecationReason": null,
  659. "description": null,
  660. "isDeprecated": false,
  661. "name": "possibleTypes",
  662. "type": {
  663. "kind": "LIST",
  664. "name": null,
  665. "ofType": {
  666. "kind": "NON_NULL",
  667. "name": null,
  668. "ofType": {
  669. "kind": "OBJECT",
  670. "name": "__Type",
  671. "ofType": null
  672. }
  673. }
  674. }
  675. },
  676. {
  677. "args": [
  678. {
  679. "defaultValue": "false",
  680. "description": null,
  681. "name": "includeDeprecated",
  682. "type": {
  683. "kind": "SCALAR",
  684. "name": "Boolean",
  685. "ofType": null
  686. }
  687. }
  688. ],
  689. "deprecationReason": null,
  690. "description": null,
  691. "isDeprecated": false,
  692. "name": "enumValues",
  693. "type": {
  694. "kind": "LIST",
  695. "name": null,
  696. "ofType": {
  697. "kind": "NON_NULL",
  698. "name": null,
  699. "ofType": {
  700. "kind": "OBJECT",
  701. "name": "__EnumValue",
  702. "ofType": null
  703. }
  704. }
  705. }
  706. },
  707. {
  708. "args": [],
  709. "deprecationReason": null,
  710. "description": null,
  711. "isDeprecated": false,
  712. "name": "inputFields",
  713. "type": {
  714. "kind": "LIST",
  715. "name": null,
  716. "ofType": {
  717. "kind": "NON_NULL",
  718. "name": null,
  719. "ofType": {
  720. "kind": "OBJECT",
  721. "name": "__InputValue",
  722. "ofType": null
  723. }
  724. }
  725. }
  726. },
  727. {
  728. "args": [],
  729. "deprecationReason": null,
  730. "description": null,
  731. "isDeprecated": false,
  732. "name": "ofType",
  733. "type": {
  734. "kind": "OBJECT",
  735. "name": "__Type",
  736. "ofType": null
  737. }
  738. }
  739. ],
  740. "inputFields": null,
  741. "interfaces": [],
  742. "kind": "OBJECT",
  743. "name": "__Type",
  744. "possibleTypes": null
  745. },
  746. {
  747. "description": "An enum describing what kind of type a given `__Type` is.",
  748. "enumValues": [
  749. {
  750. "deprecationReason": null,
  751. "description": "Indicates this type is a scalar.",
  752. "isDeprecated": false,
  753. "name": "SCALAR"
  754. },
  755. {
  756. "deprecationReason": null,
  757. "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.",
  758. "isDeprecated": false,
  759. "name": "OBJECT"
  760. },
  761. {
  762. "deprecationReason": null,
  763. "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.",
  764. "isDeprecated": false,
  765. "name": "INTERFACE"
  766. },
  767. {
  768. "deprecationReason": null,
  769. "description": "Indicates this type is a union. `possibleTypes` is a valid field.",
  770. "isDeprecated": false,
  771. "name": "UNION"
  772. },
  773. {
  774. "deprecationReason": null,
  775. "description": "Indicates this type is an enum. `enumValues` is a valid field.",
  776. "isDeprecated": false,
  777. "name": "ENUM"
  778. },
  779. {
  780. "deprecationReason": null,
  781. "description": "Indicates this type is an input object. `inputFields` is a valid field.",
  782. "isDeprecated": false,
  783. "name": "INPUT_OBJECT"
  784. },
  785. {
  786. "deprecationReason": null,
  787. "description": "Indicates this type is a list. `ofType` is a valid field.",
  788. "isDeprecated": false,
  789. "name": "LIST"
  790. },
  791. {
  792. "deprecationReason": null,
  793. "description": "Indicates this type is a non-null. `ofType` is a valid field.",
  794. "isDeprecated": false,
  795. "name": "NON_NULL"
  796. }
  797. ],
  798. "fields": null,
  799. "inputFields": null,
  800. "interfaces": null,
  801. "kind": "ENUM",
  802. "name": "__TypeKind",
  803. "possibleTypes": null
  804. },
  805. {
  806. "description": "The `Boolean` scalar type represents `true` or `false`.",
  807. "enumValues": null,
  808. "fields": null,
  809. "inputFields": null,
  810. "interfaces": null,
  811. "kind": "SCALAR",
  812. "name": "Boolean",
  813. "possibleTypes": null
  814. },
  815. {
  816. "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",
  817. "enumValues": null,
  818. "fields": [
  819. {
  820. "args": [],
  821. "deprecationReason": null,
  822. "description": null,
  823. "isDeprecated": false,
  824. "name": "name",
  825. "type": {
  826. "kind": "NON_NULL",
  827. "name": null,
  828. "ofType": {
  829. "kind": "SCALAR",
  830. "name": "String",
  831. "ofType": null
  832. }
  833. }
  834. },
  835. {
  836. "args": [],
  837. "deprecationReason": null,
  838. "description": null,
  839. "isDeprecated": false,
  840. "name": "description",
  841. "type": {
  842. "kind": "SCALAR",
  843. "name": "String",
  844. "ofType": null
  845. }
  846. },
  847. {
  848. "args": [],
  849. "deprecationReason": null,
  850. "description": null,
  851. "isDeprecated": false,
  852. "name": "args",
  853. "type": {
  854. "kind": "NON_NULL",
  855. "name": null,
  856. "ofType": {
  857. "kind": "LIST",
  858. "name": null,
  859. "ofType": {
  860. "kind": "NON_NULL",
  861. "name": null,
  862. "ofType": {
  863. "kind": "OBJECT",
  864. "name": "__InputValue",
  865. "ofType": null
  866. }
  867. }
  868. }
  869. }
  870. },
  871. {
  872. "args": [],
  873. "deprecationReason": null,
  874. "description": null,
  875. "isDeprecated": false,
  876. "name": "type",
  877. "type": {
  878. "kind": "NON_NULL",
  879. "name": null,
  880. "ofType": {
  881. "kind": "OBJECT",
  882. "name": "__Type",
  883. "ofType": null
  884. }
  885. }
  886. },
  887. {
  888. "args": [],
  889. "deprecationReason": null,
  890. "description": null,
  891. "isDeprecated": false,
  892. "name": "isDeprecated",
  893. "type": {
  894. "kind": "NON_NULL",
  895. "name": null,
  896. "ofType": {
  897. "kind": "SCALAR",
  898. "name": "Boolean",
  899. "ofType": null
  900. }
  901. }
  902. },
  903. {
  904. "args": [],
  905. "deprecationReason": null,
  906. "description": null,
  907. "isDeprecated": false,
  908. "name": "deprecationReason",
  909. "type": {
  910. "kind": "SCALAR",
  911. "name": "String",
  912. "ofType": null
  913. }
  914. }
  915. ],
  916. "inputFields": null,
  917. "interfaces": [],
  918. "kind": "OBJECT",
  919. "name": "__Field",
  920. "possibleTypes": null
  921. },
  922. {
  923. "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",
  924. "enumValues": null,
  925. "fields": [
  926. {
  927. "args": [],
  928. "deprecationReason": null,
  929. "description": null,
  930. "isDeprecated": false,
  931. "name": "name",
  932. "type": {
  933. "kind": "NON_NULL",
  934. "name": null,
  935. "ofType": {
  936. "kind": "SCALAR",
  937. "name": "String",
  938. "ofType": null
  939. }
  940. }
  941. },
  942. {
  943. "args": [],
  944. "deprecationReason": null,
  945. "description": null,
  946. "isDeprecated": false,
  947. "name": "description",
  948. "type": {
  949. "kind": "SCALAR",
  950. "name": "String",
  951. "ofType": null
  952. }
  953. },
  954. {
  955. "args": [],
  956. "deprecationReason": null,
  957. "description": null,
  958. "isDeprecated": false,
  959. "name": "type",
  960. "type": {
  961. "kind": "NON_NULL",
  962. "name": null,
  963. "ofType": {
  964. "kind": "OBJECT",
  965. "name": "__Type",
  966. "ofType": null
  967. }
  968. }
  969. },
  970. {
  971. "args": [],
  972. "deprecationReason": null,
  973. "description": "A GraphQL-formatted string representing the default value for this input value.",
  974. "isDeprecated": false,
  975. "name": "defaultValue",
  976. "type": {
  977. "kind": "SCALAR",
  978. "name": "String",
  979. "ofType": null
  980. }
  981. }
  982. ],
  983. "inputFields": null,
  984. "interfaces": [],
  985. "kind": "OBJECT",
  986. "name": "__InputValue",
  987. "possibleTypes": null
  988. },
  989. {
  990. "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",
  991. "enumValues": null,
  992. "fields": [
  993. {
  994. "args": [],
  995. "deprecationReason": null,
  996. "description": null,
  997. "isDeprecated": false,
  998. "name": "name",
  999. "type": {
  1000. "kind": "NON_NULL",
  1001. "name": null,
  1002. "ofType": {
  1003. "kind": "SCALAR",
  1004. "name": "String",
  1005. "ofType": null
  1006. }
  1007. }
  1008. },
  1009. {
  1010. "args": [],
  1011. "deprecationReason": null,
  1012. "description": null,
  1013. "isDeprecated": false,
  1014. "name": "description",
  1015. "type": {
  1016. "kind": "SCALAR",
  1017. "name": "String",
  1018. "ofType": null
  1019. }
  1020. },
  1021. {
  1022. "args": [],
  1023. "deprecationReason": null,
  1024. "description": null,
  1025. "isDeprecated": false,
  1026. "name": "isDeprecated",
  1027. "type": {
  1028. "kind": "NON_NULL",
  1029. "name": null,
  1030. "ofType": {
  1031. "kind": "SCALAR",
  1032. "name": "Boolean",
  1033. "ofType": null
  1034. }
  1035. }
  1036. },
  1037. {
  1038. "args": [],
  1039. "deprecationReason": null,
  1040. "description": null,
  1041. "isDeprecated": false,
  1042. "name": "deprecationReason",
  1043. "type": {
  1044. "kind": "SCALAR",
  1045. "name": "String",
  1046. "ofType": null
  1047. }
  1048. }
  1049. ],
  1050. "inputFields": null,
  1051. "interfaces": [],
  1052. "kind": "OBJECT",
  1053. "name": "__EnumValue",
  1054. "possibleTypes": null
  1055. },
  1056. {
  1057. "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL’s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",
  1058. "enumValues": null,
  1059. "fields": [
  1060. {
  1061. "args": [],
  1062. "deprecationReason": null,
  1063. "description": null,
  1064. "isDeprecated": false,
  1065. "name": "name",
  1066. "type": {
  1067. "kind": "NON_NULL",
  1068. "name": null,
  1069. "ofType": {
  1070. "kind": "SCALAR",
  1071. "name": "String",
  1072. "ofType": null
  1073. }
  1074. }
  1075. },
  1076. {
  1077. "args": [],
  1078. "deprecationReason": null,
  1079. "description": null,
  1080. "isDeprecated": false,
  1081. "name": "description",
  1082. "type": {
  1083. "kind": "SCALAR",
  1084. "name": "String",
  1085. "ofType": null
  1086. }
  1087. },
  1088. {
  1089. "args": [],
  1090. "deprecationReason": null,
  1091. "description": null,
  1092. "isDeprecated": false,
  1093. "name": "locations",
  1094. "type": {
  1095. "kind": "NON_NULL",
  1096. "name": null,
  1097. "ofType": {
  1098. "kind": "LIST",
  1099. "name": null,
  1100. "ofType": {
  1101. "kind": "NON_NULL",
  1102. "name": null,
  1103. "ofType": {
  1104. "kind": "ENUM",
  1105. "name": "__DirectiveLocation",
  1106. "ofType": null
  1107. }
  1108. }
  1109. }
  1110. }
  1111. },
  1112. {
  1113. "args": [],
  1114. "deprecationReason": null,
  1115. "description": null,
  1116. "isDeprecated": false,
  1117. "name": "args",
  1118. "type": {
  1119. "kind": "NON_NULL",
  1120. "name": null,
  1121. "ofType": {
  1122. "kind": "LIST",
  1123. "name": null,
  1124. "ofType": {
  1125. "kind": "NON_NULL",
  1126. "name": null,
  1127. "ofType": {
  1128. "kind": "OBJECT",
  1129. "name": "__InputValue",
  1130. "ofType": null
  1131. }
  1132. }
  1133. }
  1134. }
  1135. },
  1136. {
  1137. "args": [],
  1138. "deprecationReason": "Use `locations`.",
  1139. "description": null,
  1140. "isDeprecated": true,
  1141. "name": "onOperation",
  1142. "type": {
  1143. "kind": "NON_NULL",
  1144. "name": null,
  1145. "ofType": {
  1146. "kind": "SCALAR",
  1147. "name": "Boolean",
  1148. "ofType": null
  1149. }
  1150. }
  1151. },
  1152. {
  1153. "args": [],
  1154. "deprecationReason": "Use `locations`.",
  1155. "description": null,
  1156. "isDeprecated": true,
  1157. "name": "onFragment",
  1158. "type": {
  1159. "kind": "NON_NULL",
  1160. "name": null,
  1161. "ofType": {
  1162. "kind": "SCALAR",
  1163. "name": "Boolean",
  1164. "ofType": null
  1165. }
  1166. }
  1167. },
  1168. {
  1169. "args": [],
  1170. "deprecationReason": "Use `locations`.",
  1171. "description": null,
  1172. "isDeprecated": true,
  1173. "name": "onField",
  1174. "type": {
  1175. "kind": "NON_NULL",
  1176. "name": null,
  1177. "ofType": {
  1178. "kind": "SCALAR",
  1179. "name": "Boolean",
  1180. "ofType": null
  1181. }
  1182. }
  1183. }
  1184. ],
  1185. "inputFields": null,
  1186. "interfaces": [],
  1187. "kind": "OBJECT",
  1188. "name": "__Directive",
  1189. "possibleTypes": null
  1190. },
  1191. {
  1192. "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",
  1193. "enumValues": [
  1194. {
  1195. "deprecationReason": null,
  1196. "description": "Location adjacent to a query operation.",
  1197. "isDeprecated": false,
  1198. "name": "QUERY"
  1199. },
  1200. {
  1201. "deprecationReason": null,
  1202. "description": "Location adjacent to a mutation operation.",
  1203. "isDeprecated": false,
  1204. "name": "MUTATION"
  1205. },
  1206. {
  1207. "deprecationReason": null,
  1208. "description": "Location adjacent to a field.",
  1209. "isDeprecated": false,
  1210. "name": "FIELD"
  1211. },
  1212. {
  1213. "deprecationReason": null,
  1214. "description": "Location adjacent to a fragment definition.",
  1215. "isDeprecated": false,
  1216. "name": "FRAGMENT_DEFINITION"
  1217. },
  1218. {
  1219. "deprecationReason": null,
  1220. "description": "Location adjacent to a fragment spread.",
  1221. "isDeprecated": false,
  1222. "name": "FRAGMENT_SPREAD"
  1223. },
  1224. {
  1225. "deprecationReason": null,
  1226. "description": "Location adjacent to an inline fragment.",
  1227. "isDeprecated": false,
  1228. "name": "INLINE_FRAGMENT"
  1229. }
  1230. ],
  1231. "fields": null,
  1232. "inputFields": null,
  1233. "interfaces": null,
  1234. "kind": "ENUM",
  1235. "name": "__DirectiveLocation",
  1236. "possibleTypes": null
  1237. }
  1238. ]
  1239. }
  1240. }
  1241. ]]
  1242. describe('introspection', function()
  1243. local rootValue = {}
  1244. local variables = {}
  1245. local operationName = 'IntrospectionQuery'
  1246. local response = execute(schema, parse(introspection_query), rootValue, variables, operationName)
  1247. local expected = cjson.decode(introspection_expected_json)
  1248. assert:set_parameter("TableFormatLevel", 10)
  1249. local compare_by_name = function(a,b) return a.name < b.name end
  1250. table.sort(response.__schema.directives, compare_by_name)
  1251. table.sort(expected.__schema.directives, compare_by_name)
  1252. table.sort(response.__schema.types, compare_by_name)
  1253. table.sort(expected.__schema.types, compare_by_name)
  1254. for i,v in ipairs(expected.__schema.types) do
  1255. if v.fields ~= cjson.null then table.sort(v.fields, compare_by_name) end
  1256. if v.enumValues ~= cjson.null then table.sort(v.enumValues, compare_by_name) end
  1257. end
  1258. for i,v in ipairs(response.__schema.types) do
  1259. if v.fields ~= cjson.null then table.sort(v.fields, compare_by_name) end
  1260. if v.enumValues ~= cjson.null then table.sort(v.enumValues, compare_by_name) end
  1261. end
  1262. it('basic json equality test', function()
  1263. assert.are.same(cjson.decode('{"a":1, "b":2}'),{b = 2, a = 1})
  1264. end)
  1265. it('root nodes are set', function()
  1266. assert.is.truthy(response.__schema)
  1267. assert.is.truthy(response.__schema.directives)
  1268. assert.is.truthy(response.__schema.mutationType)
  1269. assert.is.truthy(response.__schema.queryType)
  1270. assert.is.truthy(response.__schema.types)
  1271. end)
  1272. it('mutationType match', function()
  1273. assert.are.same(expected.__schema.mutationType, response.__schema.mutationType)
  1274. end)
  1275. it('queryType match', function()
  1276. assert.are.same(expected.__schema.queryType, response.__schema.queryType)
  1277. end)
  1278. it('root types are same', function()
  1279. local expected = util.map(expected.__schema.types, function ( t ) return t.name end)
  1280. local response = util.map(response.__schema.types, function ( t ) return t.name end)
  1281. table.sort(expected)
  1282. table.sort(response)
  1283. assert.are.same(expected, response)
  1284. end)
  1285. it('types match', function()
  1286. assert.are.same(expected.__schema.types, response.__schema.types)
  1287. end)
  1288. it('directives match', function()
  1289. assert.are.same(expected.__schema.directives, response.__schema.directives)
  1290. end)
  1291. it('all match', function()
  1292. assert.are.same(expected, response)
  1293. end)
  1294. end)