I am building an api with laravel and laravel-lighthouse. I wrote a type system where you can register types like "person" or "organization" and attach fields to them. These types live in my database and are created and read by my lighthouse graphql implementation. These "virtual" types are then registered with the schema as described in the lighthouse documentation. I got queries and mutations for
- reading and manipulating the types (or classes if you want to call them that)
- reading and manipulating the instances (on an abstract level)
type Query {
objectTypes(
orderBy: [ObjectTypesOrderByOrderByClause!]
first: Int = 10
page: Int
): ObjectTypePaginator
attributeTypes(
orderBy: [attributeTypesOrderByOrderByClause!]
first: Int = 10
page: Int
): AttributeTypePaginator
objects(
orderBy: [ObjectsOrderByOrderByClause!]
first: Int = 10
page: Int
): ObjectPaginator
attributes(
orderBy: [AttributesOrderByOrderByClause!]
first: Int = 10
page: Int
): AttributePaginator
}
type Mutation {
createObjectType(input: CreateObjectTypeInput!): ObjectType!
createAttributeType(input: CreateAttributeTypeInput!): AttributeType!
updateObjectType(input: UpdateObjectTypeInput!): ObjectType!
updateAttributeType(input: UpdateAttributeTypeInput!): AttributeType!
deleteObjectType(input: DeleteObjectTypeInput!): ObjectType!
deleteAttributeType(input: DeleteAttributeTypeInput!): AttributeType!
createObject(input: CreateObjectInput!): Object!
createAttribute(input: CreateAttributeInput!): Attribute!
updateObject(input: UpdateObjectInput!): Object!
updateAttribute(input: UpdateAttributeInput!): Attribute!
deleteObject(input: DeleteObjectInput!): Object!
deleteAttribute(input: DeleteAttributeInput!): Attribute!
}
In the next step I'd like to register queries and mutations for managing instances of these types directly (e.g. createPerson(input: CreatePersonInput!): Person!). What I think would be appropriate is creating a resolver for each CRUD method that handles all the object types, but instead of reimplementing all the checks and validation I wrote for manipulating the abstract object instances I'd like to query the existing queries and mutations and present the result as the appropriate object.
TL;DR
Can I resolve queries and mutations by querying the schema without making an additional http request (internally respectively)