"""This is a custom built-in Scalar type from LightHouse. It handles Carbon dates""" scalar DateTime @scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")
type User { id: ID! name: String! email: String! created_at: DateTime! updated_at: DateTime! posts: [Post] @hasMany }
type Post { id: ID! title: String! content: String! user: User! @belongsTo comments: [Comment] @hasMany }
classLatestPost { /** * Return a value for the field. * * @param null $rootValue Usually contains the result returned from the parent field. In this case, it is always `null`. * @param array $args The arguments that were passed into the field. * @param GraphQLContext|null $context Arbitrary data that is shared between all fields of a single query. * @param ResolveInfo $resolveInfo Information about the query itself, such as the execution state, the field name, path to the field from the root, and more. * * @return mixed */ publicfunctionresolve($rootValue, array$args, GraphQLContext $context = null, ResolveInfo $resolveInfo) { returnPost::all()->last(); } }