Dynamic Schema Generation #
GRAPI’s most powerful feature is its ability to automatically generate comprehensive GraphQL schemas directly from your M-Files vault structure.
Schema Generation Process #
- Vault Analysis: Connects to M-Files via TRAPI to retrieve complete vault schema
- Type Creation: Generates GraphQL object types for each M-Files object type
- Property Mapping: Maps M-Files properties to appropriate GraphQL scalar and object types
- Relationship Resolution: Creates lookup relationships between object types
- Filter Generation: Automatically creates comprehensive filter input types
- Query Registration: Registers query resolvers for each object type
Schema Introspection #
Available through GraphQL Playground or Postman.
Multi-Vault Schema Structure #
When multiple vaults are configured, GRAPI creates vault-specific namespaces:
type Query {
# Vault-specific queries (nested structure) production {
documents(where: DocumentFilterInput, limit: Int): [Document!]!
customers(where: CustomerFilterInput, limit: Int): [Customer!]!
document(id: Int!): Document
customer(id: Int!): Customer
}
development {
documents(where: DocumentFilterInput, limit: Int): [Document!]!
customers(where: CustomerFilterInput, limit: Int): [Customer!]!
document(id: Int!): Document
customer(id: Int!): Customer
}
# Schema management refreshSchema(vaultName: String): SchemaRefreshResult!
refreshAll: SchemaRefreshAllResult!
}
Generated Object Types #
Each M-Files object type becomes a GraphQL type with flattened properties:
type Document {
# M-Files system properties id: Int!
objectType: Int!
version: Int!
title: String!
createdUtc: DateTime
lastModifiedUtc: DateTime
isCheckedOut: Boolean!
isDeleted: Boolean!
# Custom properties (flattened from M-Files properties) nameOrTitle: String description: String documentDate: DateTime
documentNumber: String isActive: Boolean priority: Float # Lookup properties (automatically resolved) customer: Customer
documentType: ValueListItem
keywords: [ValueListItem!]
# File attachments files: [MFilesObjectFile!]
}
Value List Integration #
Value list properties are typed as structured objects:
type ValueListItem {
itemId: Int!
displayValue: String!
name: String}
Schema Management #
Use these mutations to refresh GraphQL schemas when vault structures or value lists change.
Refresh Single Vault Schema #
mutation RefreshProductionSchema {
refreshSchema(vaultName: "Production") {
success
message
objectTypeCount
valueListCount
refreshedAt
vaultName
}
}
Refresh All Vault Schemas #
mutation RefreshAllSchemas {
refreshAll {
success
message
totalVaults
successfulVaults
failedVaults
results {
success
message
vaultName
objectTypeCount
valueListCount
}
}
}
Schema Refresh Response Models #
Response objects returned by schema refresh mutations.
SchemaRefreshResult #
{
"success": true,
"message": "Schema refreshed successfully",
"objectTypeCount": 15,
"valueListCount": 8,
"refreshedAt": "2024-01-15T14:30:00Z",
"vaultName": "Production"
}
SchemaRefreshAllResult #
{
"success": true,
"message": "All schemas refreshed successfully",
"totalVaults": 2,
"successfulVaults": 2,
"failedVaults": 0,
"results": [
{
"success": true,
"message": "Schema refreshed successfully",
"vaultName": "Production",
"objectTypeCount": 15,
"valueListCount": 8
},
{
"success": true,
"message": "Schema refreshed successfully",
"vaultName": "Development",
"objectTypeCount": 12,
"valueListCount": 6
}
]
}