webonyx/graphql-php
PHP implementation of the GraphQL specification, based on graphql-js. Build schemas, types, and execute queries/mutations in your PHP apps. Widely used, well-tested, and documented with examples and class reference.
[@oneOf](https://github.com/oneOf) coercion https://github.com/webonyx/graphql-php/pull/1891assertValid() https://github.com/webonyx/graphql-php/pull/1886types for per-schema built-in scalar overrides, not typeLoader https://github.com/webonyx/graphql-php/pull/1884parseLiteral not called on per-schema built-in scalar overrides for inline arguments https://github.com/webonyx/graphql-php/pull/1880types config or typeLoader, without global side effects https://github.com/webonyx/graphql-php/pull/1869Type::builtInScalars() and Type::BUILT_IN_SCALAR_NAMES aligning with GraphQL spec terminology https://github.com/webonyx/graphql-php/pull/1869Directive::builtInDirectives() and Directive::isBuiltInDirective() aligning with GraphQL spec terminology https://github.com/webonyx/graphql-php/pull/1869Type::overrideStandardTypes() in favor of per-schema scalar overrides https://github.com/webonyx/graphql-php/pull/1869Type::getStandardTypes() in favor of Type::builtInScalars() https://github.com/webonyx/graphql-php/pull/1869Type::STANDARD_TYPE_NAMES in favor of Type::BUILT_IN_SCALAR_NAMES https://github.com/webonyx/graphql-php/pull/1869Directive::getInternalDirectives() in favor of Directive::builtInDirectives() https://github.com/webonyx/graphql-php/pull/1869Directive::isSpecifiedDirective() in favor of Directive::isBuiltInDirective() https://github.com/webonyx/graphql-php/pull/1869is_array and instanceof checks https://github.com/webonyx/graphql-php/pull/1845$result in ReferenceExecutor https://github.com/webonyx/graphql-php/pull/1780Printer::printDescription https://github.com/webonyx/graphql-php/pull/1824SyncPromise backwards compatibility https://github.com/webonyx/graphql-php/pull/1823Deferred execution https://github.com/webonyx/graphql-php/pull/1805GraphQL\Deferred::create() in favor of constructor https://github.com/webonyx/graphql-php/pull/1805Lexer name tokenization https://github.com/webonyx/graphql-php/pull/1813\Stringable interface https://github.com/webonyx/graphql-php/pull/1810Deferred memory usage optimization https://github.com/webonyx/graphql-php/pull/1790Deferred memory usage with incremental queue processing https://github.com/webonyx/graphql-php/pull/1790HasFieldsTypeImplementation https://github.com/webonyx/graphql-php/pull/1783AbstractType::resolveValue before AbstractType::resolveType https://github.com/webonyx/graphql-php/pull/1781resolveValue method to Interface and Union types https://github.com/webonyx/graphql-php/pull/1776NonNull to Type::nonNull() https://github.com/webonyx/graphql-php/pull/1757Type::getNamedType() return type https://github.com/webonyx/graphql-php/pull/1756Node with a NodeList in Visitor https://github.com/webonyx/graphql-php/pull/1754NodeVisitor return type by allowing Node https://github.com/webonyx/graphql-php/pull/1752Printer fully static https://github.com/webonyx/graphql-php/pull/1749Printer::doPrint https://github.com/webonyx/graphql-php/pull/1748isOneOf directive when extending input objects with SchemaExtender https://github.com/webonyx/graphql-php/pull/1745includeDeprecated to introspection field __Directive.args https://github.com/webonyx/graphql-php/pull/1738/commits/0dd03675dc7c971abfad86cafaf2da353778529fincludeDeprecated arguments in introspection fields non-nullable with default value false https://github.com/webonyx/graphql-php/pull/1738/commits/851ddb55d722035904191705b6d62ba56950680cisOneOf optional in introspection query https://github.com/webonyx/graphql-php/pull/1737isOneOf to introspection query https://github.com/webonyx/graphql-php/pull/1729[@oneOf](https://github.com/oneOf) directive in SchemaPrinter https://github.com/webonyx/graphql-php/pull/1727[@oneOf](https://github.com/oneOf) input object directive - enables "input unions" where exactly one field must be provided https://github.com/webonyx/graphql-php/pull/1715PhpEnumType::parseValue() https://github.com/webonyx/graphql-php/pull/1519react/promise v3 https://github.com/webonyx/graphql-php/pull/1517SchemaConfig option types https://github.com/webonyx/graphql-php/pull/1479visible https://github.com/webonyx/graphql-php/pull/1434null https://github.com/webonyx/graphql-php/pull/1422query, mutation, subscription https://github.com/webonyx/graphql-php/pull/1418queryId from Apollo-source sha256Hash if query is provided https://github.com/webonyx/graphql-php/pull/1412Parser::document(), use parse()ScopedContext interface to control cloning of the context valueSchemaPrinter with static:: to enable overridesquery and queryId, let persistedQueryLoader handle it https://github.com/webonyx/graphql-php/pull/1372PhpEnumType https://github.com/webonyx/graphql-php/pull/1368[@throws](https://github.com/throws) annotations for known correct configuration https://github.com/webonyx/graphql-php/pull/1716type and unions to ResolveInfo::getFieldSelectionWithAliases result https://github.com/webonyx/graphql-php/pull/1681ResolveInfo::getFieldSelection() https://github.com/webonyx/graphql-php/pull/1365OperationDefinitionNode.variableDefinitions is initialized[@throws](https://github.com/throws) accuratelydirectives and arguments in Node with empty NodeListResolveInfo::getFieldSelectionWithAliases https://github.com/webonyx/graphql-php/pull/1664getFieldSelectionWithAliases to class ResolveInfo https://github.com/webonyx/graphql-php/pull/1648parseValue https://github.com/webonyx/graphql-php/pull/1624BackedEnum instances by name, not value https://github.com/webonyx/graphql-php/pull/1618Helper::validateOperationParams as list https://github.com/webonyx/graphql-php/pull/1615array to list https://github.com/webonyx/graphql-php/pull/1597\BackedEnum values in GraphQL\Type\Definition\PhpEnumType https://github.com/webonyx/graphql-php/pull/1604QueryDepth validator https://github.com/webonyx/graphql-php/pull/1581unaliasedPath does not grow for each list item https://github.com/webonyx/graphql-php/pull/1579count on PHPUnit\Framework\Test https://github.com/webonyx/graphql-php/pull/1577ReferenceExecutor https://github.com/webonyx/graphql-php/pull/1570unaliasedPath to ResolveInfo https://github.com/webonyx/graphql-php/pull/1548ScopedContext for mutations https://github.com/webonyx/graphql-php/pull/1549BuildClientSchema to have any type https://github.com/webonyx/graphql-php/pull/1536RequestError https://github.com/webonyx/graphql-php/pull/1533SchemaPrinterQueryPlan for union typesQueryPlan performanceQueryPlan when querying __typename on a union typeError when failing to serialize an Enum typeType and its subclassesSerializationError over client safe Error when failing to serialize leaf typesextensions keyRequestError with useful message when clients provide an invalid JSON bodyBlockString from namespace GraphQL\Utils to GraphQL\LanguageGraphQL::getStandardDirectives(), GraphQL::getStandardTypes() and GraphQL::getStandardValidationRules()FieldDefinition to QueryComplexityType directly without an intermediary callablenullServerConfig option persistentQueryLoader to persistedQueryLoaderEnumType::parseValue() and EnumType::parseLiteral()PromiseAdapter::createRejected() to require \ThrowableNamedType out of Type: $name, $description, $config, isBuiltInType(), assertValid()Node::toArray()Directive::$config['args'] use the same definition style as FieldDefinition::$config['args']FieldArgument to ArgumentQueryPlan options from ['group-implementor-fields'] to ['groupImplementorFields' => true] in ResolveInfo::lookAhead()PromiseAdapter::convertThenable() before calling ->then() on themJSON_THROW_ON_ERROR in json_encode()assert()PromiseAdapter::all() accepts iterableIntrospection::fromSchema() returns no dataASTValidationContext to interface ValidationContextUtils::suggestionList() with the reference implementation (https://github.com/webonyx/graphql-php/issues/1075)GraphQL\Utils\AST::typeFromAST() now needs a type loader callable instead of the SchemaStandardServer" instead of """ for single line descriptionsHelper::emitResponse() private, use Helper::sendResponse()StandardServergraphql-js reference implementationDocumentValidatorassert() or schema validationHasSelectionSet::$selectionSet with HasSelectionSet::getSelectionSet()TypeDefinitionNode::$name with TypeDefinitionNode::getName()TypeExtensionNode::$name with TypeExtensionNode::getName()AST::concatAST() utilityUniqueEnumValueNamesUniqueOperationTypes (https://github.com/webonyx/graphql-php/issues/995)DocumentValidator::removeRule()Node implement JsonSerializableUniqueTypeNames (https://github.com/webonyx/graphql-php/issues/998)KnownTypeNames rule (https://github.com/webonyx/graphql-php/issues/999)UniqueArgumentDefinitionNames (https://github.com/webonyx/graphql-php/issues/1136)parseValue config option to InputObjectType to parse input value to custom value objectsortTypes to have SchemaPrinter order types alphabeticallyEnumType from PHP enumTypeInfo::getParentTypeStack() and TypeInfo::getFieldDefStack()__typenameforeach over slower functions array_map() and Utils::map()QueryPlan crash when multiple $fieldNodes are presentQueryPlan with different optionsarray or stdClass to an input objectnull parent of list in ValuesOfCorrectType::getVisitorquery and queryId, ignore queryId in that caseSchemaExtender::extend()NodeList in Node::cloneDeep()Schema::getType() on a schema built from SDL returns null for unknown types (https://github.com/webonyx/graphql-php/issues/1068)QueryComplexity ruleFormattedError::addDebugEntries() twice when using default error formattingiterable in implementations of PromiseAdapter::all()OperationParams method getOriginalInput() in favor of public property $originalInputOperationParams method isReadOnly() in favor of public property $readOnlyUtils::withErrorHandling()TypeComparators::doTypesOverlap()DocumentValidator::isError()DocumentValidator::append()Utils::getVariableType() in favor of Utils::printSafe()isDeprecated in field definition configWrappingType::getWrappedType() argument $recurse in favor of WrappingType::getInnermostType()Type::assertType()ListOfType::$ofType, ListOfType::getOfType() and NonNull::getOfType()commentDescriptions from BuildSchema::buildAST(), BuildSchema::build() and Printer::doPrint()$options from ASTDefinitionBuilderFieldDefinition::create() in favor of new FieldDefinition()GraphQL\Exception\InvalidArgumentUtils::find(), Utils::every() and Utils::invariant()bool $exitWhenDone from StandardServer::send500Error() and StandardServer::handleRequest()Schema::getAstNode() in favor of Schema::$astNodeSchema option types, use Type::overrideStandardTypes()GraphQL\Utils\TypeInfo::typeFromAST(), use GraphQL\Utils\AST::typeFromAST()StandardServer::send500Error(), handle non-GraphQL errors yourselfStandardServer::getHelper(), use new Helpercategory, use custom error formatting if you still need itType::getInternalTypes()GraphQL::execute()GraphQL::executeAndReturnResult()FormattedError::create() and FormattedError::createFromPHPError()GraphQL::setPromiseAdapter()AST::getOperation()BreakingChangesFinderDocumentValidator::isValidLiteralValue()Error::formatError() and Error::toSerializableArray()GraphQL::getInternalDirectives()Schema::isPossibleType()TypeInfoValues::valueFromAST() and Values::isValidPHPValue()InputObjectField::$typeFieldDefinition::$typeGraphQL\Validator\Rules\AbstractQuerySecurity, use GraphQL\Validator\Rules\QuerySecurityRuleGraphQL\Validator\Rules\AbstractValidationRule, use GraphQL\Validator\Rules\ValidationRuleGraphQL\Utils\FindBreakingChanges, use GraphQL\Utils\BreakingChangesFinderSchemaExtenderGraphQL\Utils\AST::getOperationAST()QueryPlan when __typename is used in the queryRefactoring:
directive.isRepeatable in BuildClientSchemaDeprecates:
Constant BreakingChangeFinder::BREAKING_CHANGE_INTERFACE_REMOVED_FROM_OBJECT.
Use BreakingChangeFinder::BREAKING_CHANGE_IMPLEMENTED_INTERFACE_REMOVED instead.
Constant value also changed from INTERFACE_REMOVED_FROM_OBJECT to IMPLEMENTED_INTERFACE_REMOVED.
Constant BreakingChangeFinder::DANGEROUS_CHANGE_INTERFACE_ADDED_TO_OBJECT
Use DANGEROUS_CHANGE_IMPLEMENTED_INTERFACE_ADDED instead.
Constant value also changed from INTERFACE_ADDED_TO_OBJECT to IMPLEMENTED_INTERFACE_ADDED.
Refactoring:
NodeList via []= (https://github.com/webonyx/graphql-php/issues/767)Error\FormattedError::prepareFormatter() to address PHP8 deprecation (https://github.com/webonyx/graphql-php/issues/742)SchemaPrinter so that it uses late static bindings when extendedDirectiveDefinitionNode->locations as NodeList<NamedNode> (fixes AST::fromArray conversion) (https://github.com/webonyx/graphql-php/issues/723)Parser::implementsInterfaces as NodeList<NamedTypeNode> (fixes AST::fromArray conversion)Parser::unionMemberTypes to match actual NodeList<NamedTypeNode>typeLoader to return a type thunk (https://github.com/webonyx/graphql-php/issues/687)Deprecates:
FieldDefinition::$type property (https://github.com/webonyx/graphql-php/issues/702)Fixes:
extend() to preserve repeatable (https://github.com/webonyx/graphql-php/issues/931)ServerRequestInterfaceiterable, not just arrayIntType constants MAX_INT and MIN_INT publicDirectiveNode#astNode in SchemaValidationContext (https://github.com/webonyx/graphql-php/issues/708)IntValueNode (https://github.com/webonyx/graphql-php/issues/691)This release brings several breaking changes. Please refer to UPGRADE document for details.
GraphQL\Deferred now extends GraphQL\Executor\Promise\Adapter\SyncPromiseBreakingChangesFinder)GraphQL\Error\Debug to GraphQL\Error\DebugFlag.GraphQL\Executor\ExecutionResult, GraphQL\Error\FormattedError and GraphQL\Server\ServerConfig do not accept boolean value anymore but int only.$positions in GraphQL\Error\Error constructor are not nullable anymore. Same can be expressed by passing an empty array.deprecationReason will now print the [@deprecated](https://github.com/deprecated) directive (only a null deprecationReason won't print the [@deprecated](https://github.com/deprecated) directive).Special thanks to @simPod, @spawnia and @shmax for their major contributions!
AST\Node::__toString() will convert node to array recursively to encode to json without errorsResolveInfo::getFieldSelection() now correctly merges fragment selections (see https://github.com/webonyx/graphql-php/issues/98)ResolveInfo::getFieldSelection() now respects inline fragmentsvalue is bool, null or float (see https://github.com/webonyx/graphql-php/issues/141)resolveType returns unexpected result (see https://github.com/webonyx/graphql-php/issues/119)GraphQL\Server now properly sets promise adapter before executing queryGraphQL\Server (see https://github.com/webonyx/graphql-php/issues/82)TypeResolutionStrategy (see https://github.com/webonyx/graphql-php/issues/69)This release brings several minor breaking changes. Please refer to UPGRADE document for details.
New features:
null value (as required by latest GraphQL spec)path entry in errors produced by resolvers for better debuggingresolveType for interface/union is now allowed to return string name of typeImprovements:
This release brings several breaking changes. Please refer to UPGRADE document for details.
New features and notable changes:
category and extensions are displayed under extensions key when using default formatting (https://github.com/webonyx/graphql-php/issues/389)GraphQL::useExperimentalExecutor().
Please try it and post your feedback at https://github.com/webonyx/graphql-php/issues/397
(as it may become the default one in future)
extendSchema from the reference implementation under GraphQL\Utils\SchemaExtender (https://github.com/webonyx/graphql-php/issues/362)GraphQL::overrideStandardTypes(array $types) (https://github.com/webonyx/graphql-php/issues/401)Debug::RETHROW_UNSAFE_EXCEPTIONS which would only rethrow app-specific exceptions (https://github.com/webonyx/graphql-php/issues/337)data entry from response on top-level error (https://github.com/webonyx/graphql-php/issues/281)Improvements:
operationName (instead of operation) in inputtypes option of the schema (see https://github.com/webonyx/graphql-php/issues/174).This release brings little changes but there are two reasons why it is released as major version:
"false" accidentally sent in variables was converted to boolean true
and passed to field arguments. In the new version, such input will produce an error
(which is a spec-compliant behavior).Improvements:
BuildSchema now have reference to AST node with corresponding AST definition (in $astNode property).graphql file)This release brings several breaking changes. Please refer to UPGRADE document for details.
New features and notable changes:
Improvements:
Deprecations and breaking changes - see UPGRADE document.
Look at GitHub Releases Page.
How can I help you explore Laravel packages today?