Skip to content

Instantly share code, notes, and snippets.

@colllin
Last active February 9, 2021 23:24
Show Gist options
  • Save colllin/2f336e8a196f1ef712397e55e9e1ae50 to your computer and use it in GitHub Desktop.
Save colllin/2f336e8a196f1ef712397e55e9e1ae50 to your computer and use it in GitHub Desktop.
FaunaDB Clear all GraphQL metadata

From Leo via slack on Jan 3rd, 2020 in #graphql channel:

This is the script you should run in order to delete all of the GraphQL metadata for the current DB (it won't delete any actual data):

// Remove GraphQL metadata from Collections, Functions, and Indexes
Foreach(Paginate(Collections(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))
Foreach(Paginate(Functions(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))
Foreach(Paginate(Indexes(), {size:10000}), Lambda('ref', Update(Var('ref'), {data: {gql: null}})))

And lastly, you should delete the GraphQL metadata from the DB itself. In order to do so, you will need to run the following query from a parent DB:

// Remove GraphQL metadata from DB
// Run this from the parent DB
Update(Database("some-database"), {data: {gql: null}})

Once all of the GraphQL metadata is erased, you could try to import the schema with the new changes from scratch. Let me know if having this done by the Console for you, with some sort of option, will be helpful for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment