Download the PHP package oligus/schema without Composer
On this page you can find all versions of the php package oligus/schema. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oligus/schema
More information about oligus/schema
Files in oligus/schema
Informations about the package schema
GraphQL Schema
GraphQL schema library.
Install
Contents
Quick start
Types
Type modifiers
Scalar
Built in scalar types
Objects
Interfaces
Enums
Inputs
Fields
Arguments
Argument values
Development
Quick start
Result:
Types
The fundamental unit of any GraphQL Schema is the type. There are six kinds of named type definitions in GraphQL, and two wrapping types.
Available types:
Type modifiers
Type modifiers are used in conjunction with types, add modifier to a type to modify the type in question.
Definition
TypeModifier(?bool $nullable, ?bool $listable, ?bool $nullableList)
Modifiers
Type | Syntax | Example |
---|---|---|
Nullable Type | \ |
String |
Non-null Type | \ |
String! |
List Type | [\ |
[String] |
List of Non-null Types | [\ |
[String!] |
Non-null List Type | [\ |
[String]! |
Non-null List of Non-null Types | [\ |
[String!]! |
Examples
Result:
Scalar
Scalar types represent primitive leaf values in a GraphQL type system. GraphQL responses take the form of a hierarchical tree; the leaves on these trees are GraphQL scalars.
Definition
Scalar(string $name, ?string $description)
Examples
Result:
Built in scalar types
GraphQL provides a basic set of well‐defined Scalar types. A GraphQL server should support all of these types.
Built in types: Boolean, Float, ID, Integer, String
Definition
<TYPE>Type(?TypeModifier $modifier)
Where \<TYPE> is Boolean, Float, ID, Integer or String
Examples
Result:
Objects
GraphQL queries are hierarchical and composed, describing a tree of information. While Scalar types describe the leaf values of these hierarchical queries, Objects describe the intermediate levels.
Definition
ObjectType(string $name, ?string $description = null)
Examples
Result:
Implement interface
Result:
Interfaces
GraphQL interfaces represent a list of named fields and their arguments. GraphQL objects can then implement these interfaces which requires that the object type will define all fields defined by those interfaces.
Definition
InterfaceType(string $name, ?string $description = null)
Examples
Result:
Unions
GraphQL Unions represent an object that could be one of a list of GraphQL Object types, but provides for no guaranteed fields between those types. They also differ from interfaces in that Object types declare what interfaces they implement, but are not aware of what unions contain them.
Definitions
UnionType(string $name, ?string $description = null)
Add object:
addObjectType(ObjectType $objectType): void
Examples
Result:
Enums
GraphQL Enum types, like scalar types, also represent leaf values in a GraphQL type system. However Enum types describe the set of possible values.
Definitions
EnumType(string $name, ?string $description = null, array $enums = [])
Add enum:
add(string $enum)
Examples
Result:
Directives
A GraphQL schema describes directives which are used to annotate various parts of a GraphQL document as an indicator that they should be evaluated differently by a validator, executor, or client tool such as a code generator.
Definitions
EnumType(string $name, ?string $description = null, array $enums = [])
Add locations:
add(ExecutableDirectiveLocation $location)
Examples
Result:
Inputs
Fields may accept arguments to configure their behavior. These inputs are often scalars or enums, but they sometimes need to represent more complex values.
Definition
InputType(string $name, ?string $description = null)
Add field:
addField(Field $field): void
Examples
Result:
Fields
A selection set is primarily composed of fields. A field describes one discrete piece of information available to request within a selection set.
Definition
Field(string $name, Type $type, ?TypeModifier $typeModifier, ?string $description)
Examples
Result:
With type modifier:
Result:
With type argument:
Arguments
Fields are conceptually functions which return values, and occasionally accept arguments which alter their behavior. These arguments often map directly to function arguments within a GraphQL server’s implementation.
Definition
Argument(string $name, Type $type, ?TypeModifier $typeModifier, ?Value $defaultVale)
Examples
Result:
With type modifier:
With type default value:
Argument values
Set simple scalar values for default values in arguments.
Definition
Value(mixed $value)
Available values:
ValueBoolean, ValueFloat, ValueInteger, ValueNull, ValueString
Examples
Development
Download and build docker container
Access docker image