async-graphql icon indicating copy to clipboard operation
async-graphql copied to clipboard

Can you register a new dynamic schema type while server is running?

Open jacklund opened this issue 1 year ago • 0 comments

I'm writing a GraphQL app where users can create new types dynamically through the API, something along the lines of:

mutation {
    createObjectType("person")
    addTypeField("person", "name", "String")
    addTypeField("person", "age", "Int")
}

which will create a new type person with the given fields, which will be part of the GraphQL schema, with appropriate CRUD functions. So, for instance, a new person could be added using:

mutation {
    addPerson("Fred Flintstone", 40)
}

or something along those lines. Is there a way to do this using the dynamic-schema stuff? I can definitely see how to create the objects dynamically, but I'm at a loss as to how to add them to the schema registry while the server is running (i.e., from within the handlers).

Thanks, and apologies if this is a n00b question. :smile_cat:

jacklund avatar Aug 05 '24 23:08 jacklund