Alter graphql realm schema

I’m attempting to add GraphQL to an existing cluster. I’m not sure if cluster is the correct term. I have an ExpressJS API that connects to a DB I have in Mongo Atlas. I followed the youtube video “GraphQL: The Easy Way to do the Hard Stuff”. It went well. I attempted to create a schema for one of my collections with the assumption that it would be easy to add more collections to the schema later. I was wrong. I cannot find a way to alter the schema to add the other collections in the DB to the schema.

Is there a quick way to do this? Should I delete the Realm instance and start over?

Hi there -

You don’t need to delete your Realm instance. To add to your GraphQL Schema, you simply need to create/generate a schema for another collection. To do that you can do the following:

  1. click the (+) button next to the ‘mongodb-atlas’ to add a new collection or click on an existing collection in your db (greyed out collections).

  1. Configure Rules (a quick way is to choose a template).

  2. Click on ‘Schema’ and either define the json schema for the documents in your collection or generate it (if you have data in your schema already).

Once you save and deploy the GraphQL schema should update which you can verify by going to ‘GraphQL’ --> ‘Schema’

Hope that answers your question, if not, feel free to reply to this thread with follow-up questions.

1 Like