PHP Class GraphQL\Type\Definition\ObjectType
Almost all of the GraphQL types you define will be object types. Object types
have a name, but most importantly describe their fields.
Example:
var AddressType = new GraphQLObjectType({
name: 'Address',
fields: {
street: { type: GraphQLString },
number: { type: GraphQLInt },
formatted: {
type: GraphQLString,
resolve(obj) {
return obj.number + ' ' + obj.street
}
}
}
});
When two types need to refer to each other, or a type needs to refer to
itself in a field, you can use a function expression (aka a closure or a
thunk) to supply the fields lazily.
Example:
var PersonType = new GraphQLObjectType({
name: 'Person',
fields: () => ({
name: { type: GraphQLString },
bestFriend: { type: PersonType },
})
});
Afficher le fichier
Open project: webonyx/graphql-php
Class Usage Examples
Méthodes publiques
Méthodes publiques
Method Details
__construct()
public méthode
getField()
public méthode
getFields()
public méthode
public getFields ( ) : FieldDefinition[] |
Résultat |
FieldDefinition[] |
|
getInterfaces()
public méthode
public getInterfaces ( ) : InterfaceType[] |
Résultat |
InterfaceType[] |
|
implementsInterface()
public méthode
isTypeOf()
public méthode
Property Details
$config public_oe property
Keeping reference of config for late bindings and custom app-level metadata
public array $config |
Résultat |
array |
|
$resolveFieldFn public_oe property
public callable $resolveFieldFn |
Résultat |
callable |
|