reference.md 49.6 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172
# GraphQL\GraphQL
This is the primary facade for fulfilling GraphQL operations.
See [related documentation](executing-queries.md).

**Class Methods:** 
```php
/**
 * Executes graphql query.
 *
 * More sophisticated GraphQL servers, such as those which persist queries,
 * may wish to separate the validation and execution phases to a static time
 * tooling step, and a server runtime step.
 *
 * Available options:
 *
 * schema:
 *    The GraphQL type system to use when validating and executing a query.
 * source:
 *    A GraphQL language formatted string representing the requested operation.
 * rootValue:
 *    The value provided as the first argument to resolver functions on the top
 *    level type (e.g. the query object type).
 * context:
 *    The value provided as the third argument to all resolvers.
 *    Use this to pass current session, user data, etc
 * variableValues:
 *    A mapping of variable name to runtime value to use for all variables
 *    defined in the requestString.
 * operationName:
 *    The name of the operation to use if requestString contains multiple
 *    possible operations. Can be omitted if requestString contains only
 *    one operation.
 * fieldResolver:
 *    A resolver function to use when one is not provided by the schema.
 *    If not provided, the default field resolver is used (which looks for a
 *    value on the source value with the field's name).
 * validationRules:
 *    A set of rules for query validation step. Default value is all available rules.
 *    Empty array would allow to skip query validation (may be convenient for persisted
 *    queries which are validated before persisting and assumed valid during execution)
 *
 * @api
 * @param \GraphQL\Type\Schema $schema
 * @param string|DocumentNode $source
 * @param mixed $rootValue
 * @param mixed $context
 * @param array|null $variableValues
 * @param string|null $operationName
 * @param callable $fieldResolver
 * @param array $validationRules
 *
 * @return ExecutionResult
 */
static function executeQuery(
    GraphQL\Type\Schema $schema,
    $source,
    $rootValue = null,
    $context = null,
    $variableValues = null,
    $operationName = null,
    callable $fieldResolver = null,
    array $validationRules = null
)
```

```php
/**
 * Same as executeQuery(), but requires PromiseAdapter and always returns a Promise.
 * Useful for Async PHP platforms.
 *
 * @api
 * @param PromiseAdapter $promiseAdapter
 * @param \GraphQL\Type\Schema $schema
 * @param string|DocumentNode $source
 * @param mixed $rootValue
 * @param mixed $context
 * @param array|null $variableValues
 * @param string|null $operationName
 * @param callable $fieldResolver
 * @param array $validationRules
 *
 * @return Promise
 */
static function promiseToExecute(
    GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter,
    GraphQL\Type\Schema $schema,
    $source,
    $rootValue = null,
    $context = null,
    $variableValues = null,
    $operationName = null,
    callable $fieldResolver = null,
    array $validationRules = null
)
```

```php
/**
 * Returns directives defined in GraphQL spec
 *
 * @api
 * @return Directive[]
 */
static function getStandardDirectives()
```

```php
/**
 * Returns types defined in GraphQL spec
 *
 * @api
 * @return Type[]
 */
static function getStandardTypes()
```

```php
/**
 * Returns standard validation rules implementing GraphQL spec
 *
 * @api
 * @return AbstractValidationRule[]
 */
static function getStandardValidationRules()
```
# GraphQL\Type\Definition\Type
Registry of standard GraphQL types
and a base class for all other types.

**Class Methods:** 
```php
/**
 * @api
 * @return IDType
 */
static function id()
```

```php
/**
 * @api
 * @return StringType
 */
static function string()
```

```php
/**
 * @api
 * @return BooleanType
 */
static function boolean()
```

```php
/**
 * @api
 * @return IntType
 */
static function int()
```

```php
/**
 * @api
 * @return FloatType
 */
static function float()
```

```php
/**
 * @api
 * @param Type|ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType|NonNull $wrappedType
 * @return ListOfType
 */
static function listOf($wrappedType)
```

```php
/**
 * @api
 * @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType $wrappedType
 * @return NonNull
 */
static function nonNull($wrappedType)
```

```php
/**
 * @api
 * @param Type $type
 * @return bool
 */
static function isInputType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return bool
 */
static function isOutputType($type)
```

```php
/**
 * @api
 * @param $type
 * @return bool
 */
static function isLeafType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return bool
 */
static function isCompositeType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return bool
 */
static function isAbstractType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return bool
 */
static function isType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
 */
static function getNullableType($type)
```

```php
/**
 * @api
 * @param Type $type
 * @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType
 */
static function getNamedType($type)
```
# GraphQL\Type\Definition\ResolveInfo
Structure containing information useful for field resolution process.
Passed as 3rd argument to every field resolver. See [docs on field resolving (data fetching)](data-fetching.md).

**Class Props:** 
```php
/**
 * The name of the field being resolved
 *
 * @api
 * @var string
 */
public $fieldName;

/**
 * AST of all nodes referencing this field in the query.
 *
 * @api
 * @var FieldNode[]
 */
public $fieldNodes;

/**
 * Expected return type of the field being resolved
 *
 * @api
 * @var ScalarType|ObjectType|InterfaceType|UnionType|EnumType|ListOfType|NonNull
 */
public $returnType;

/**
 * Parent type of the field being resolved
 *
 * @api
 * @var ObjectType
 */
public $parentType;

/**
 * Path to this field from the very root value
 *
 * @api
 * @var array
 */
public $path;

/**
 * Instance of a schema used for execution
 *
 * @api
 * @var Schema
 */
public $schema;

/**
 * AST of all fragments defined in query
 *
 * @api
 * @var FragmentDefinitionNode[]
 */
public $fragments;

/**
 * Root value passed to query execution
 *
 * @api
 * @var mixed
 */
public $rootValue;

/**
 * AST of operation definition node (query, mutation)
 *
 * @api
 * @var OperationDefinitionNode
 */
public $operation;

/**
 * Array of variables passed to query execution
 *
 * @api
 * @var array
 */
public $variableValues;
```

**Class Methods:** 
```php
/**
 * Helper method that returns names of all fields selected in query for
 * $this->fieldName up to $depth levels
 *
 * Example:
 * query MyQuery{
 * {
 *   root {
 *     id,
 *     nested {
 *      nested1
 *      nested2 {
 *        nested3
 *      }
 *     }
 *   }
 * }
 *
 * Given this ResolveInfo instance is a part of "root" field resolution, and $depth === 1,
 * method will return:
 * [
 *     'id' => true,
 *     'nested' => [
 *         nested1 => true,
 *         nested2 => true
 *     ]
 * ]
 *
 * Warning: this method it is a naive implementation which does not take into account
 * conditional typed fragments. So use it with care for fields of interface and union types.
 *
 * @api
 * @param int $depth How many levels to include in output
 * @return array
 */
function getFieldSelection($depth = 0)
```
# GraphQL\Language\DirectiveLocation
List of available directive locations

**Class Constants:** 
```php
const QUERY = "QUERY";
const MUTATION = "MUTATION";
const SUBSCRIPTION = "SUBSCRIPTION";
const FIELD = "FIELD";
const FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION";
const FRAGMENT_SPREAD = "FRAGMENT_SPREAD";
const INLINE_FRAGMENT = "INLINE_FRAGMENT";
const SCHEMA = "SCHEMA";
const SCALAR = "SCALAR";
const OBJECT = "OBJECT";
const FIELD_DEFINITION = "FIELD_DEFINITION";
const ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION";
const IFACE = "INTERFACE";
const UNION = "UNION";
const ENUM = "ENUM";
const ENUM_VALUE = "ENUM_VALUE";
const INPUT_OBJECT = "INPUT_OBJECT";
const INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION";
```

# GraphQL\Type\SchemaConfig
Schema configuration class.
Could be passed directly to schema constructor. List of options accepted by **create** method is
[described in docs](type-system/schema.md#configuration-options).

Usage example:

    $config = SchemaConfig::create()
        ->setQuery($myQueryType)
        ->setTypeLoader($myTypeLoader);

    $schema = new Schema($config);

**Class Methods:** 
```php
/**
 * Converts an array of options to instance of SchemaConfig
 * (or just returns empty config when array is not passed).
 *
 * @api
 * @param array $options
 * @return SchemaConfig
 */
static function create(array $options = [])
```

```php
/**
 * @api
 * @param ObjectType $query
 * @return SchemaConfig
 */
function setQuery($query)
```

```php
/**
 * @api
 * @param ObjectType $mutation
 * @return SchemaConfig
 */
function setMutation($mutation)
```

```php
/**
 * @api
 * @param ObjectType $subscription
 * @return SchemaConfig
 */
function setSubscription($subscription)
```

```php
/**
 * @api
 * @param Type[]|callable $types
 * @return SchemaConfig
 */
function setTypes($types)
```

```php
/**
 * @api
 * @param Directive[] $directives
 * @return SchemaConfig
 */
function setDirectives(array $directives)
```

```php
/**
 * @api
 * @param callable $typeLoader
 * @return SchemaConfig
 */
function setTypeLoader(callable $typeLoader)
```

```php
/**
 * @api
 * @return ObjectType
 */
function getQuery()
```

```php
/**
 * @api
 * @return ObjectType
 */
function getMutation()
```

```php
/**
 * @api
 * @return ObjectType
 */
function getSubscription()
```

```php
/**
 * @api
 * @return Type[]
 */
function getTypes()
```

```php
/**
 * @api
 * @return Directive[]
 */
function getDirectives()
```

```php
/**
 * @api
 * @return callable
 */
function getTypeLoader()
```
# GraphQL\Type\Schema
Schema Definition (see [related docs](type-system/schema.md))

A Schema is created by supplying the root types of each type of operation:
query, mutation (optional) and subscription (optional). A schema definition is
then supplied to the validator and executor. Usage Example:

    $schema = new GraphQL\Type\Schema([
      'query' => $MyAppQueryRootType,
      'mutation' => $MyAppMutationRootType,
    ]);

Or using Schema Config instance:

    $config = GraphQL\Type\SchemaConfig::create()
        ->setQuery($MyAppQueryRootType)
        ->setMutation($MyAppMutationRootType);

    $schema = new GraphQL\Type\Schema($config);

**Class Methods:** 
```php
/**
 * Schema constructor.
 *
 * @api
 * @param array|SchemaConfig $config
 */
function __construct($config)
```

```php
/**
 * Returns schema query type
 *
 * @api
 * @return ObjectType
 */
function getQueryType()
```

```php
/**
 * Returns schema mutation type
 *
 * @api
 * @return ObjectType|null
 */
function getMutationType()
```

```php
/**
 * Returns schema subscription
 *
 * @api
 * @return ObjectType|null
 */
function getSubscriptionType()
```

```php
/**
 * @api
 * @return SchemaConfig
 */
function getConfig()
```

```php
/**
 * Returns array of all types in this schema. Keys of this array represent type names, values are instances
 * of corresponding type definitions
 *
 * This operation requires full schema scan. Do not use in production environment.
 *
 * @api
 * @return Type[]
 */
function getTypeMap()
```

```php
/**
 * Returns type by it's name
 *
 * @api
 * @param string $name
 * @return Type
 */
function getType($name)
```

```php
/**
 * Returns all possible concrete types for given abstract type
 * (implementations for interfaces and members of union type for unions)
 *
 * This operation requires full schema scan. Do not use in production environment.
 *
 * @api
 * @param AbstractType $abstractType
 * @return ObjectType[]
 */
function getPossibleTypes(GraphQL\Type\Definition\AbstractType $abstractType)
```

```php
/**
 * Returns true if object type is concrete type of given abstract type
 * (implementation for interfaces and members of union type for unions)
 *
 * @api
 * @param AbstractType $abstractType
 * @param ObjectType $possibleType
 * @return bool
 */
function isPossibleType(
    GraphQL\Type\Definition\AbstractType $abstractType,
    GraphQL\Type\Definition\ObjectType $possibleType
)
```

```php
/**
 * Returns a list of directives supported by this schema
 *
 * @api
 * @return Directive[]
 */
function getDirectives()
```

```php
/**
 * Returns instance of directive by name
 *
 * @api
 * @param $name
 * @return Directive
 */
function getDirective($name)
```

```php
/**
 * Validates schema.
 *
 * This operation requires full schema scan. Do not use in production environment.
 *
 * @api
 * @return InvariantViolation[]|Error[]
 */
function validate()
```

```php
/**
 * Validates schema.
 *
 * This operation requires full schema scan. Do not use in production environment.
 *
 * @api
 * @throws InvariantViolation
 */
function assertValid()
```
# GraphQL\Language\Parser
Parses string containing GraphQL query or [type definition](type-system/type-language.md) to Abstract Syntax Tree.

**Class Methods:** 
```php
/**
 * Given a GraphQL source, parses it into a `GraphQL\Language\AST\DocumentNode`.
 * Throws `GraphQL\Error\SyntaxError` if a syntax error is encountered.
 *
 * Available options:
 *
 * noLocation: boolean,
 * (By default, the parser creates AST nodes that know the location
 * in the source that they correspond to. This configuration flag
 * disables that behavior for performance or testing.)
 *
 * experimentalFragmentVariables: boolean,
 * (If enabled, the parser will understand and parse variable definitions
 * contained in a fragment definition. They'll be represented in the
 * `variableDefinitions` field of the FragmentDefinitionNode.
 *
 * The syntax is identical to normal, query-defined variables. For example:
 *
 *   fragment A($var: Boolean = false) on T  {
 *     ...
 *   }
 *
 * Note: this feature is experimental and may change or be removed in the
 * future.)
 *
 * @api
 * @param Source|string $source
 * @param array $options
 * @return DocumentNode
 * @throws SyntaxError
 */
static function parse($source, array $options = [])
```

```php
/**
 * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
 * that value.
 * Throws `GraphQL\Error\SyntaxError` if a syntax error is encountered.
 *
 * This is useful within tools that operate upon GraphQL Values directly and
 * in isolation of complete GraphQL documents.
 *
 * Consider providing the results to the utility function: `GraphQL\Utils\AST::valueFromAST()`.
 *
 * @api
 * @param Source|string $source
 * @param array $options
 * @return BooleanValueNode|EnumValueNode|FloatValueNode|IntValueNode|ListValueNode|ObjectValueNode|StringValueNode|VariableNode
 */
static function parseValue($source, array $options = [])
```

```php
/**
 * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
 * that type.
 * Throws `GraphQL\Error\SyntaxError` if a syntax error is encountered.
 *
 * This is useful within tools that operate upon GraphQL Types directly and
 * in isolation of complete GraphQL documents.
 *
 * Consider providing the results to the utility function: `GraphQL\Utils\AST::typeFromAST()`.
 *
 * @api
 * @param Source|string $source
 * @param array $options
 * @return ListTypeNode|NameNode|NonNullTypeNode
 */
static function parseType($source, array $options = [])
```
# GraphQL\Language\Printer
Prints AST to string. Capable of printing GraphQL queries and Type definition language.
Useful for pretty-printing queries or printing back AST for logging, documentation, etc.

Usage example:

```php
$query = 'query myQuery {someField}';
$ast = GraphQL\Language\Parser::parse($query);
$printed = GraphQL\Language\Printer::doPrint($ast);
```

**Class Methods:** 
```php
/**
 * Prints AST to string. Capable of printing GraphQL queries and Type definition language.
 *
 * @api
 * @param Node $ast
 * @return string
 */
static function doPrint($ast)
```
# GraphQL\Language\Visitor
Utility for efficient AST traversal and modification.

`visit()` will walk through an AST using a depth first traversal, calling
the visitor's enter function at each node in the traversal, and calling the
leave function after visiting that node and all of it's child nodes.

By returning different values from the enter and leave functions, the
behavior of the visitor can be altered, including skipping over a sub-tree of
the AST (by returning false), editing the AST by returning a value or null
to remove the value, or to stop the whole traversal by returning BREAK.

When using `visit()` to edit an AST, the original AST will not be modified, and
a new version of the AST with the changes applied will be returned from the
visit function.

    $editedAST = Visitor::visit($ast, [
      'enter' => function ($node, $key, $parent, $path, $ancestors) {
        // return
        //   null: no action
        //   Visitor::skipNode(): skip visiting this node
        //   Visitor::stop(): stop visiting altogether
        //   Visitor::removeNode(): delete this node
        //   any value: replace this node with the returned value
      },
      'leave' => function ($node, $key, $parent, $path, $ancestors) {
        // return
        //   null: no action
        //   Visitor::stop(): stop visiting altogether
        //   Visitor::removeNode(): delete this node
        //   any value: replace this node with the returned value
      }
    ]);

Alternatively to providing enter() and leave() functions, a visitor can
instead provide functions named the same as the [kinds of AST nodes](reference.md#graphqllanguageastnodekind),
or enter/leave visitors at a named key, leading to four permutations of
visitor API:

1) Named visitors triggered when entering a node a specific kind.

    Visitor::visit($ast, [
      'Kind' => function ($node) {
        // enter the "Kind" node
      }
    ]);

2) Named visitors that trigger upon entering and leaving a node of
   a specific kind.

    Visitor::visit($ast, [
      'Kind' => [
        'enter' => function ($node) {
          // enter the "Kind" node
        }
        'leave' => function ($node) {
          // leave the "Kind" node
        }
      ]
    ]);

3) Generic visitors that trigger upon entering and leaving any node.

    Visitor::visit($ast, [
      'enter' => function ($node) {
        // enter any node
      },
      'leave' => function ($node) {
        // leave any node
      }
    ]);

4) Parallel visitors for entering and leaving nodes of a specific kind.

    Visitor::visit($ast, [
      'enter' => [
        'Kind' => function($node) {
          // enter the "Kind" node
        }
      },
      'leave' => [
        'Kind' => function ($node) {
          // leave the "Kind" node
        }
      ]
    ]);

**Class Methods:** 
```php
/**
 * Visit the AST (see class description for details)
 *
 * @api
 * @param Node $root
 * @param array $visitor
 * @param array $keyMap
 * @return Node|mixed
 * @throws \Exception
 */
static function visit($root, $visitor, $keyMap = null)
```

```php
/**
 * Returns marker for visitor break
 *
 * @api
 * @return VisitorOperation
 */
static function stop()
```

```php
/**
 * Returns marker for skipping current node
 *
 * @api
 * @return VisitorOperation
 */
static function skipNode()
```

```php
/**
 * Returns marker for removing a node
 *
 * @api
 * @return VisitorOperation
 */
static function removeNode()
```
# GraphQL\Language\AST\NodeKind


**Class Constants:** 
```php
const NAME = "Name";
const DOCUMENT = "Document";
const OPERATION_DEFINITION = "OperationDefinition";
const VARIABLE_DEFINITION = "VariableDefinition";
const VARIABLE = "Variable";
const SELECTION_SET = "SelectionSet";
const FIELD = "Field";
const ARGUMENT = "Argument";
const FRAGMENT_SPREAD = "FragmentSpread";
const INLINE_FRAGMENT = "InlineFragment";
const FRAGMENT_DEFINITION = "FragmentDefinition";
const INT = "IntValue";
const FLOAT = "FloatValue";
const STRING = "StringValue";
const BOOLEAN = "BooleanValue";
const ENUM = "EnumValue";
const NULL = "NullValue";
const LST = "ListValue";
const OBJECT = "ObjectValue";
const OBJECT_FIELD = "ObjectField";
const DIRECTIVE = "Directive";
const NAMED_TYPE = "NamedType";
const LIST_TYPE = "ListType";
const NON_NULL_TYPE = "NonNullType";
const SCHEMA_DEFINITION = "SchemaDefinition";
const OPERATION_TYPE_DEFINITION = "OperationTypeDefinition";
const SCALAR_TYPE_DEFINITION = "ScalarTypeDefinition";
const OBJECT_TYPE_DEFINITION = "ObjectTypeDefinition";
const FIELD_DEFINITION = "FieldDefinition";
const INPUT_VALUE_DEFINITION = "InputValueDefinition";
const INTERFACE_TYPE_DEFINITION = "InterfaceTypeDefinition";
const UNION_TYPE_DEFINITION = "UnionTypeDefinition";
const ENUM_TYPE_DEFINITION = "EnumTypeDefinition";
const ENUM_VALUE_DEFINITION = "EnumValueDefinition";
const INPUT_OBJECT_TYPE_DEFINITION = "InputObjectTypeDefinition";
const SCALAR_TYPE_EXTENSION = "ScalarTypeExtension";
const OBJECT_TYPE_EXTENSION = "ObjectTypeExtension";
const INTERFACE_TYPE_EXTENSION = "InterfaceTypeExtension";
const UNION_TYPE_EXTENSION = "UnionTypeExtension";
const ENUM_TYPE_EXTENSION = "EnumTypeExtension";
const INPUT_OBJECT_TYPE_EXTENSION = "InputObjectTypeExtension";
const DIRECTIVE_DEFINITION = "DirectiveDefinition";
```

# GraphQL\Executor\Executor
Implements the "Evaluating requests" section of the GraphQL specification.

**Class Methods:** 
```php
/**
 * Executes DocumentNode against given $schema.
 *
 * Always returns ExecutionResult and never throws. All errors which occur during operation
 * execution are collected in `$result->errors`.
 *
 * @api
 * @param Schema $schema
 * @param DocumentNode $ast
 * @param $rootValue
 * @param $contextValue
 * @param array|\ArrayAccess $variableValues
 * @param null $operationName
 * @param callable $fieldResolver
 *
 * @return ExecutionResult|Promise
 */
static function execute(
    GraphQL\Type\Schema $schema,
    GraphQL\Language\AST\DocumentNode $ast,
    $rootValue = null,
    $contextValue = null,
    $variableValues = null,
    $operationName = null,
    callable $fieldResolver = null
)
```

```php
/**
 * Same as execute(), but requires promise adapter and returns a promise which is always
 * fulfilled with an instance of ExecutionResult and never rejected.
 *
 * Useful for async PHP platforms.
 *
 * @api
 * @param PromiseAdapter $promiseAdapter
 * @param Schema $schema
 * @param DocumentNode $ast
 * @param null $rootValue
 * @param null $contextValue
 * @param null $variableValues
 * @param null $operationName
 * @param callable|null $fieldResolver
 * @return Promise
 */
static function promiseToExecute(
    GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter,
    GraphQL\Type\Schema $schema,
    GraphQL\Language\AST\DocumentNode $ast,
    $rootValue = null,
    $contextValue = null,
    $variableValues = null,
    $operationName = null,
    callable $fieldResolver = null
)
```
# GraphQL\Executor\ExecutionResult
Returned after [query execution](executing-queries.md).
Represents both - result of successful execution and of a failed one
(with errors collected in `errors` prop)

Could be converted to [spec-compliant](https://facebook.github.io/graphql/#sec-Response-Format)
serializable array using `toArray()`

**Class Props:** 
```php
/**
 * Data collected from resolvers during query execution
 *
 * @api
 * @var array
 */
public $data;

/**
 * Errors registered during query execution.
 *
 * If an error was caused by exception thrown in resolver, $error->getPrevious() would
 * contain original exception.
 *
 * @api
 * @var \GraphQL\Error\Error[]
 */
public $errors;

/**
 * User-defined serializable array of extensions included in serialized result.
 * Conforms to
 *
 * @api
 * @var array
 */
public $extensions;
```

**Class Methods:** 
```php
/**
 * Define custom error formatting (must conform to http://facebook.github.io/graphql/#sec-Errors)
 *
 * Expected signature is: function (GraphQL\Error\Error $error): array
 *
 * Default formatter is "GraphQL\Error\FormattedError::createFromException"
 *
 * Expected returned value must be an array:
 * array(
 *    'message' => 'errorMessage',
 *    // ... other keys
 * );
 *
 * @api
 * @param callable $errorFormatter
 * @return $this
 */
function setErrorFormatter(callable $errorFormatter)
```

```php
/**
 * Define custom logic for error handling (filtering, logging, etc).
 *
 * Expected handler signature is: function (array $errors, callable $formatter): array
 *
 * Default handler is:
 * function (array $errors, callable $formatter) {
 *     return array_map($formatter, $errors);
 * }
 *
 * @api
 * @param callable $handler
 * @return $this
 */
function setErrorsHandler(callable $handler)
```

```php
/**
 * Converts GraphQL query result to spec-compliant serializable array using provided
 * errors handler and formatter.
 *
 * If debug argument is passed, output of error formatter is enriched which debugging information
 * ("debugMessage", "trace" keys depending on flags).
 *
 * $debug argument must be either bool (only adds "debugMessage" to result) or sum of flags from
 * GraphQL\Error\Debug
 *
 * @api
 * @param bool|int $debug
 * @return array
 */
function toArray($debug = false)
```
# GraphQL\Executor\Promise\PromiseAdapter
Provides a means for integration of async PHP platforms ([related docs](data-fetching.md#async-php))

**Interface Methods:** 
```php
/**
 * Return true if the value is a promise or a deferred of the underlying platform
 *
 * @api
 * @param mixed $value
 * @return bool
 */
function isThenable($value)
```

```php
/**
 * Converts thenable of the underlying platform into GraphQL\Executor\Promise\Promise instance
 *
 * @api
 * @param object $thenable
 * @return Promise
 */
function convertThenable($thenable)
```

```php
/**
 * Accepts our Promise wrapper, extracts adopted promise out of it and executes actual `then` logic described
 * in Promises/A+ specs. Then returns new wrapped instance of GraphQL\Executor\Promise\Promise.
 *
 * @api
 * @param Promise $promise
 * @param callable|null $onFulfilled
 * @param callable|null $onRejected
 *
 * @return Promise
 */
function then(
    GraphQL\Executor\Promise\Promise $promise,
    callable $onFulfilled = null,
    callable $onRejected = null
)
```

```php
/**
 * Creates a Promise
 *
 * Expected resolver signature:
 *     function(callable $resolve, callable $reject)
 *
 * @api
 * @param callable $resolver
 * @return Promise
 */
function create(callable $resolver)
```

```php
/**
 * Creates a fulfilled Promise for a value if the value is not a promise.
 *
 * @api
 * @param mixed $value
 * @return Promise
 */
function createFulfilled($value = null)
```

```php
/**
 * Creates a rejected promise for a reason if the reason is not a promise. If
 * the provided reason is a promise, then it is returned as-is.
 *
 * @api
 * @param \Throwable $reason
 * @return Promise
 */
function createRejected($reason)
```

```php
/**
 * Given an array of promises (or values), returns a promise that is fulfilled when all the
 * items in the array are fulfilled.
 *
 * @api
 * @param array $promisesOrValues Promises or values.
 * @return Promise
 */
function all(array $promisesOrValues)
```
# GraphQL\Validator\DocumentValidator
Implements the "Validation" section of the spec.

Validation runs synchronously, returning an array of encountered errors, or
an empty array if no errors were encountered and the document is valid.

A list of specific validation rules may be provided. If not provided, the
default list of rules defined by the GraphQL specification will be used.

Each validation rule is an instance of GraphQL\Validator\Rules\AbstractValidationRule
which returns a visitor (see the [GraphQL\Language\Visitor API](reference.md#graphqllanguagevisitor)).

Visitor methods are expected to return an instance of [GraphQL\Error\Error](reference.md#graphqlerrorerror),
or array of such instances when invalid.

Optionally a custom TypeInfo instance may be provided. If not provided, one
will be created from the provided schema.

**Class Methods:** 
```php
/**
 * Primary method for query validation. See class description for details.
 *
 * @api
 * @param Schema $schema
 * @param DocumentNode $ast
 * @param AbstractValidationRule[]|null $rules
 * @param TypeInfo|null $typeInfo
 * @return Error[]
 */
static function validate(
    GraphQL\Type\Schema $schema,
    GraphQL\Language\AST\DocumentNode $ast,
    array $rules = null,
    GraphQL\Utils\TypeInfo $typeInfo = null
)
```

```php
/**
 * Returns all global validation rules.
 *
 * @api
 * @return AbstractValidationRule[]
 */
static function allRules()
```

```php
/**
 * Returns global validation rule by name. Standard rules are named by class name, so
 * example usage for such rules:
 *
 * $rule = DocumentValidator::getRule(GraphQL\Validator\Rules\QueryComplexity::class);
 *
 * @api
 * @param string $name
 * @return AbstractValidationRule
 */
static function getRule($name)
```

```php
/**
 * Add rule to list of global validation rules
 *
 * @api
 * @param AbstractValidationRule $rule
 */
static function addRule(GraphQL\Validator\Rules\AbstractValidationRule $rule)
```
# GraphQL\Error\Error
Describes an Error found during the parse, validate, or
execute phases of performing a GraphQL operation. In addition to a message
and stack trace, it also includes information about the locations in a
GraphQL document and/or execution result that correspond to the Error.

When the error was caused by an exception thrown in resolver, original exception
is available via `getPrevious()`.

Also read related docs on [error handling](error-handling.md)

Class extends standard PHP `\Exception`, so all standard methods of base `\Exception` class
are available in addition to those listed below.

**Class Constants:** 
```php
const CATEGORY_GRAPHQL = "graphql";
const CATEGORY_INTERNAL = "internal";
```

**Class Methods:** 
```php
/**
 * An array of locations within the source GraphQL document which correspond to this error.
 *
 * Each entry has information about `line` and `column` within source GraphQL document:
 * $location->line;
 * $location->column;
 *
 * Errors during validation often contain multiple locations, for example to
 * point out to field mentioned in multiple fragments. Errors during execution include a
 * single location, the field which produced the error.
 *
 * @api
 * @return SourceLocation[]
 */
function getLocations()
```

```php
/**
 * Returns an array describing the path from the root value to the field which produced this error.
 * Only included for execution errors.
 *
 * @api
 * @return array|null
 */
function getPath()
```
# GraphQL\Error\Warning
Encapsulates warnings produced by the library.

Warnings can be suppressed (individually or all) if required.
Also it is possible to override warning handler (which is **trigger_error()** by default)

**Class Constants:** 
```php
const WARNING_ASSIGN = 2;
const WARNING_CONFIG = 4;
const WARNING_FULL_SCHEMA_SCAN = 8;
const WARNING_CONFIG_DEPRECATION = 16;
const WARNING_NOT_A_TYPE = 32;
const ALL = 63;
```

**Class Methods:** 
```php
/**
 * Sets warning handler which can intercept all system warnings.
 * When not set, trigger_error() is used to notify about warnings.
 *
 * @api
 * @param callable|null $warningHandler
 */
static function setWarningHandler(callable $warningHandler = null)
```

```php
/**
 * Suppress warning by id (has no effect when custom warning handler is set)
 *
 * Usage example:
 * Warning::suppress(Warning::WARNING_NOT_A_TYPE)
 *
 * When passing true - suppresses all warnings.
 *
 * @api
 * @param bool|int $suppress
 */
static function suppress($suppress = true)
```

```php
/**
 * Re-enable previously suppressed warning by id
 *
 * Usage example:
 * Warning::suppress(Warning::WARNING_NOT_A_TYPE)
 *
 * When passing true - re-enables all warnings.
 *
 * @api
 * @param bool|int $enable
 */
static function enable($enable = true)
```
# GraphQL\Error\ClientAware
This interface is used for [default error formatting](error-handling.md).

Only errors implementing this interface (and returning true from `isClientSafe()`)
will be formatted with original error message.

All other errors will be formatted with generic "Internal server error".

**Interface Methods:** 
```php
/**
 * Returns true when exception message is safe to be displayed to a client.
 *
 * @api
 * @return bool
 */
function isClientSafe()
```

```php
/**
 * Returns string describing a category of the error.
 *
 * Value "graphql" is reserved for errors produced by query parsing or validation, do not use it.
 *
 * @api
 * @return string
 */
function getCategory()
```
# GraphQL\Error\Debug
Collection of flags for [error debugging](error-handling.md#debugging-tools).

**Class Constants:** 
```php
const INCLUDE_DEBUG_MESSAGE = 1;
const INCLUDE_TRACE = 2;
const RETHROW_INTERNAL_EXCEPTIONS = 4;
```

# GraphQL\Error\FormattedError
This class is used for [default error formatting](error-handling.md).
It converts PHP exceptions to [spec-compliant errors](https://facebook.github.io/graphql/#sec-Errors)
and provides tools for error debugging.

**Class Methods:** 
```php
/**
 * Set default error message for internal errors formatted using createFormattedError().
 * This value can be overridden by passing 3rd argument to `createFormattedError()`.
 *
 * @api
 * @param string $msg
 */
static function setInternalErrorMessage($msg)
```

```php
/**
 * Standard GraphQL error formatter. Converts any exception to array
 * conforming to GraphQL spec.
 *
 * This method only exposes exception message when exception implements ClientAware interface
 * (or when debug flags are passed).
 *
 * For a list of available debug flags see GraphQL\Error\Debug constants.
 *
 * @api
 * @param \Throwable $e
 * @param bool|int $debug
 * @param string $internalErrorMessage
 * @return array
 * @throws \Throwable
 */
static function createFromException($e, $debug = false, $internalErrorMessage = null)
```

```php
/**
 * Returns error trace as serializable array
 *
 * @api
 * @param \Throwable $error
 * @return array
 */
static function toSafeTrace($error)
```
# GraphQL\Server\StandardServer
GraphQL server compatible with both: [express-graphql](https://github.com/graphql/express-graphql)
and [Apollo Server](https://github.com/apollographql/graphql-server).
Usage Example:

    $server = new StandardServer([
      'schema' => $mySchema
    ]);
    $server->handleRequest();

Or using [ServerConfig](reference.md#graphqlserverserverconfig) instance:

    $config = GraphQL\Server\ServerConfig::create()
        ->setSchema($mySchema)
        ->setContext($myContext);

    $server = new GraphQL\Server\StandardServer($config);
    $server->handleRequest();

See [dedicated section in docs](executing-queries.md#using-server) for details.

**Class Methods:** 
```php
/**
 * Converts and exception to error and sends spec-compliant HTTP 500 error.
 * Useful when an exception is thrown somewhere outside of server execution context
 * (e.g. during schema instantiation).
 *
 * @api
 * @param \Throwable $error
 * @param bool $debug
 * @param bool $exitWhenDone
 */
static function send500Error($error, $debug = false, $exitWhenDone = false)
```

```php
/**
 * Creates new instance of a standard GraphQL HTTP server
 *
 * @api
 * @param ServerConfig|array $config
 */
function __construct($config)
```

```php
/**
 * Parses HTTP request, executes and emits response (using standard PHP `header` function and `echo`)
 *
 * By default (when $parsedBody is not set) it uses PHP globals to parse a request.
 * It is possible to implement request parsing elsewhere (e.g. using framework Request instance)
 * and then pass it to the server.
 *
 * See `executeRequest()` if you prefer to emit response yourself
 * (e.g. using Response object of some framework)
 *
 * @api
 * @param OperationParams|OperationParams[] $parsedBody
 * @param bool $exitWhenDone
 */
function handleRequest($parsedBody = null, $exitWhenDone = false)
```

```php
/**
 * Executes GraphQL operation and returns execution result
 * (or promise when promise adapter is different from SyncPromiseAdapter).
 *
 * By default (when $parsedBody is not set) it uses PHP globals to parse a request.
 * It is possible to implement request parsing elsewhere (e.g. using framework Request instance)
 * and then pass it to the server.
 *
 * PSR-7 compatible method executePsrRequest() does exactly this.
 *
 * @api
 * @param OperationParams|OperationParams[] $parsedBody
 * @return ExecutionResult|ExecutionResult[]|Promise
 * @throws InvariantViolation
 */
function executeRequest($parsedBody = null)
```

```php
/**
 * Executes PSR-7 request and fulfills PSR-7 response.
 *
 * See `executePsrRequest()` if you prefer to create response yourself
 * (e.g. using specific JsonResponse instance of some framework).
 *
 * @api
 * @param ServerRequestInterface $request
 * @param ResponseInterface $response
 * @param StreamInterface $writableBodyStream
 * @return ResponseInterface|Promise
 */
function processPsrRequest(
    Psr\Http\Message\ServerRequestInterface $request,
    Psr\Http\Message\ResponseInterface $response,
    Psr\Http\Message\StreamInterface $writableBodyStream
)
```

```php
/**
 * Executes GraphQL operation and returns execution result
 * (or promise when promise adapter is different from SyncPromiseAdapter)
 *
 * @api
 * @param ServerRequestInterface $request
 * @return ExecutionResult|ExecutionResult[]|Promise
 */
function executePsrRequest(Psr\Http\Message\ServerRequestInterface $request)
```

```php
/**
 * Returns an instance of Server helper, which contains most of the actual logic for
 * parsing / validating / executing request (which could be re-used by other server implementations)
 *
 * @api
 * @return Helper
 */
function getHelper()
```
# GraphQL\Server\ServerConfig
Server configuration class.
Could be passed directly to server constructor. List of options accepted by **create** method is
[described in docs](executing-queries.md#server-configuration-options).

Usage example:

    $config = GraphQL\Server\ServerConfig::create()
        ->setSchema($mySchema)
        ->setContext($myContext);

    $server = new GraphQL\Server\StandardServer($config);

**Class Methods:** 
```php
/**
 * Converts an array of options to instance of ServerConfig
 * (or just returns empty config when array is not passed).
 *
 * @api
 * @param array $config
 * @return ServerConfig
 */
static function create(array $config = [])
```

```php
/**
 * @api
 * @param Schema $schema
 * @return $this
 */
function setSchema(GraphQL\Type\Schema $schema)
```

```php
/**
 * @api
 * @param mixed|\Closure $context
 * @return $this
 */
function setContext($context)
```

```php
/**
 * @api
 * @param mixed|\Closure $rootValue
 * @return $this
 */
function setRootValue($rootValue)
```

```php
/**
 * Expects function(Throwable $e) : array
 *
 * @api
 * @param callable $errorFormatter
 * @return $this
 */
function setErrorFormatter(callable $errorFormatter)
```

```php
/**
 * Expects function(array $errors, callable $formatter) : array
 *
 * @api
 * @param callable $handler
 * @return $this
 */
function setErrorsHandler(callable $handler)
```

```php
/**
 * Set validation rules for this server.
 *
 * @api
 * @param array|callable
 * @return $this
 */
function setValidationRules($validationRules)
```

```php
/**
 * @api
 * @param callable $fieldResolver
 * @return $this
 */
function setFieldResolver(callable $fieldResolver)
```

```php
/**
 * Expects function($queryId, OperationParams $params) : string|DocumentNode
 *
 * This function must return query string or valid DocumentNode.
 *
 * @api
 * @param callable $persistentQueryLoader
 * @return $this
 */
function setPersistentQueryLoader(callable $persistentQueryLoader)
```

```php
/**
 * Set response debug flags. See GraphQL\Error\Debug class for a list of all available flags
 *
 * @api
 * @param bool|int $set
 * @return $this
 */
function setDebug($set = true)
```

```php
/**
 * Allow batching queries (disabled by default)
 *
 * @api
 * @param bool $enableBatching
 * @return $this
 */
function setQueryBatching($enableBatching)
```

```php
/**
 * @api
 * @param PromiseAdapter $promiseAdapter
 * @return $this
 */
function setPromiseAdapter(GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter)
```
# GraphQL\Server\Helper
Contains functionality that could be re-used by various server implementations

**Class Methods:** 
```php
/**
 * Parses HTTP request using PHP globals and returns GraphQL OperationParams
 * contained in this request. For batched requests it returns an array of OperationParams.
 *
 * This function does not check validity of these params
 * (validation is performed separately in validateOperationParams() method).
 *
 * If $readRawBodyFn argument is not provided - will attempt to read raw request body
 * from `php://input` stream.
 *
 * Internally it normalizes input to $method, $bodyParams and $queryParams and
 * calls `parseRequestParams()` to produce actual return value.
 *
 * For PSR-7 request parsing use `parsePsrRequest()` instead.
 *
 * @api
 * @param callable|null $readRawBodyFn
 * @return OperationParams|OperationParams[]
 * @throws RequestError
 */
function parseHttpRequest(callable $readRawBodyFn = null)
```

```php
/**
 * Parses normalized request params and returns instance of OperationParams
 * or array of OperationParams in case of batch operation.
 *
 * Returned value is a suitable input for `executeOperation` or `executeBatch` (if array)
 *
 * @api
 * @param string $method
 * @param array $bodyParams
 * @param array $queryParams
 * @return OperationParams|OperationParams[]
 * @throws RequestError
 */
function parseRequestParams($method, array $bodyParams, array $queryParams)
```

```php
/**
 * Checks validity of OperationParams extracted from HTTP request and returns an array of errors
 * if params are invalid (or empty array when params are valid)
 *
 * @api
 * @param OperationParams $params
 * @return Error[]
 */
function validateOperationParams(GraphQL\Server\OperationParams $params)
```

```php
/**
 * Executes GraphQL operation with given server configuration and returns execution result
 * (or promise when promise adapter is different from SyncPromiseAdapter)
 *
 * @api
 * @param ServerConfig $config
 * @param OperationParams $op
 *
 * @return ExecutionResult|Promise
 */
function executeOperation(GraphQL\Server\ServerConfig $config, GraphQL\Server\OperationParams $op)
```

```php
/**
 * Executes batched GraphQL operations with shared promise queue
 * (thus, effectively batching deferreds|promises of all queries at once)
 *
 * @api
 * @param ServerConfig $config
 * @param OperationParams[] $operations
 * @return ExecutionResult[]|Promise
 */
function executeBatch(GraphQL\Server\ServerConfig $config, array $operations)
```

```php
/**
 * Send response using standard PHP `header()` and `echo`.
 *
 * @api
 * @param Promise|ExecutionResult|ExecutionResult[] $result
 * @param bool $exitWhenDone
 */
function sendResponse($result, $exitWhenDone = false)
```

```php
/**
 * Converts PSR-7 request to OperationParams[]
 *
 * @api
 * @param ServerRequestInterface $request
 * @return array|Helper
 * @throws RequestError
 */
function parsePsrRequest(Psr\Http\Message\ServerRequestInterface $request)
```

```php
/**
 * Converts query execution result to PSR-7 response
 *
 * @api
 * @param Promise|ExecutionResult|ExecutionResult[] $result
 * @param ResponseInterface $response
 * @param StreamInterface $writableBodyStream
 * @return Promise|ResponseInterface
 */
function toPsrResponse(
    $result,
    Psr\Http\Message\ResponseInterface $response,
    Psr\Http\Message\StreamInterface $writableBodyStream
)
```
# GraphQL\Server\OperationParams
Structure representing parsed HTTP parameters for GraphQL operation

**Class Props:** 
```php
/**
 * Id of the query (when using persistent queries).
 *
 * Valid aliases (case-insensitive):
 * - id
 * - queryId
 * - documentId
 *
 * @api
 * @var string
 */
public $queryId;

/**
 * @api
 * @var string
 */
public $query;

/**
 * @api
 * @var string
 */
public $operation;

/**
 * @api
 * @var array
 */
public $variables;
```

**Class Methods:** 
```php
/**
 * Creates an instance from given array
 *
 * @api
 * @param array $params
 * @param bool $readonly
 * @return OperationParams
 */
static function create(array $params, $readonly = false)
```

```php
/**
 * @api
 * @param string $key
 * @return mixed
 */
function getOriginalInput($key)
```

```php
/**
 * Indicates that operation is executed in read-only context
 * (e.g. via HTTP GET request)
 *
 * @api
 * @return bool
 */
function isReadOnly()
```
# GraphQL\Utils\BuildSchema
Build instance of `GraphQL\Type\Schema` out of type language definition (string or parsed AST)
See [section in docs](type-system/type-language.md) for details.

**Class Methods:** 
```php
/**
 * This takes the ast of a schema document produced by the parse function in
 * GraphQL\Language\Parser.
 *
 * If no schema definition is provided, then it will look for types named Query
 * and Mutation.
 *
 * Given that AST it constructs a GraphQL\Type\Schema. The resulting schema
 * has no resolve methods, so execution will use default resolvers.
 *
 * Accepts options as a second argument:
 *
 *    - commentDescriptions:
 *        Provide true to use preceding comments as the description.
 *
 *
 * @api
 * @param DocumentNode $ast
 * @param array $options
 * @return Schema
 * @throws Error
 */
static function buildAST(GraphQL\Language\AST\DocumentNode $ast, array $options = [])
```

```php
/**
 * A helper function to build a GraphQLSchema directly from a source
 * document.
 *
 * @api
 * @param DocumentNode|Source|string $source
 * @param array $options
 * @return Schema
 */
static function build($source, array $options = [])
```
# GraphQL\Utils\AST
Various utilities dealing with AST

**Class Methods:** 
```php
/**
 * Convert representation of AST as an associative array to instance of GraphQL\Language\AST\Node.
 *
 * For example:
 *
 * ```php
 * AST::fromArray([
 *     'kind' => 'ListValue',
 *     'values' => [
 *         ['kind' => 'StringValue', 'value' => 'my str'],
 *         ['kind' => 'StringValue', 'value' => 'my other str']
 *     ],
 *     'loc' => ['start' => 21, 'end' => 25]
 * ]);
 * ```
 *
 * Will produce instance of `ListValueNode` where `values` prop is a lazily-evaluated `NodeList`
 * returning instances of `StringValueNode` on access.
 *
 * This is a reverse operation for AST::toArray($node)
 *
 * @api
 * @param array $node
 * @return Node
 */
static function fromArray(array $node)
```

```php
/**
 * Convert AST node to serializable array
 *
 * @api
 * @param Node $node
 * @return array
 */
static function toArray(GraphQL\Language\AST\Node $node)
```

```php
/**
 * Produces a GraphQL Value AST given a PHP value.
 *
 * Optionally, a GraphQL type may be provided, which will be used to
 * disambiguate between value primitives.
 *
 * | PHP Value     | GraphQL Value        |
 * | ------------- | -------------------- |
 * | Object        | Input Object         |
 * | Assoc Array   | Input Object         |
 * | Array         | List                 |
 * | Boolean       | Boolean              |
 * | String        | String / Enum Value  |
 * | Int           | Int                  |
 * | Float         | Int / Float          |
 * | Mixed         | Enum Value           |
 * | null          | NullValue            |
 *
 * @api
 * @param $value
 * @param InputType $type
 * @return ObjectValueNode|ListValueNode|BooleanValueNode|IntValueNode|FloatValueNode|EnumValueNode|StringValueNode|NullValueNode
 */
static function astFromValue($value, GraphQL\Type\Definition\InputType $type)
```

```php
/**
 * Produces a PHP value given a GraphQL Value AST.
 *
 * A GraphQL type must be provided, which will be used to interpret different
 * GraphQL Value literals.
 *
 * Returns `null` when the value could not be validly coerced according to
 * the provided type.
 *
 * | GraphQL Value        | PHP Value     |
 * | -------------------- | ------------- |
 * | Input Object         | Assoc Array   |
 * | List                 | Array         |
 * | Boolean              | Boolean       |
 * | String               | String        |
 * | Int / Float          | Int / Float   |
 * | Enum Value           | Mixed         |
 * | Null Value           | null          |
 *
 * @api
 * @param $valueNode
 * @param InputType $type
 * @param null $variables
 * @return array|null|\stdClass
 * @throws \Exception
 */
static function valueFromAST($valueNode, GraphQL\Type\Definition\InputType $type, $variables = null)
```

```php
/**
 * Produces a PHP value given a GraphQL Value AST.
 *
 * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value
 * will reflect the provided GraphQL value AST.
 *
 * | GraphQL Value        | PHP Value     |
 * | -------------------- | ------------- |
 * | Input Object         | Assoc Array   |
 * | List                 | Array         |
 * | Boolean              | Boolean       |
 * | String               | String        |
 * | Int / Float          | Int / Float   |
 * | Enum                 | Mixed         |
 * | Null                 | null          |
 *
 * @api
 * @param Node $valueNode
 * @param array|null $variables
 * @return mixed
 * @throws \Exception
 */
static function valueFromASTUntyped($valueNode, array $variables = null)
```

```php
/**
 * Returns type definition for given AST Type node
 *
 * @api
 * @param Schema $schema
 * @param NamedTypeNode|ListTypeNode|NonNullTypeNode $inputTypeNode
 * @return Type
 * @throws \Exception
 */
static function typeFromAST(GraphQL\Type\Schema $schema, $inputTypeNode)
```

```php
/**
 * Returns operation type ("query", "mutation" or "subscription") given a document and operation name
 *
 * @api
 * @param DocumentNode $document
 * @param string $operationName
 * @return bool
 */
static function getOperation(GraphQL\Language\AST\DocumentNode $document, $operationName = null)
```
# GraphQL\Utils\SchemaPrinter
Given an instance of Schema, prints it in GraphQL type language.

**Class Methods:** 
```php
/**
 * Accepts options as a second argument:
 *
 *    - commentDescriptions:
 *        Provide true to use preceding comments as the description.
 * @api
 * @param Schema $schema
 * @return string
 */
static function doPrint(GraphQL\Type\Schema $schema, array $options = [])
```

```php
/**
 * @api
 * @param Schema $schema
 * @return string
 */
static function printIntrosepctionSchema(GraphQL\Type\Schema $schema, array $options = [])
```