Skip to content

Instantly share code, notes, and snippets.

@ficapy
Created May 13, 2024 07:00
Show Gist options
  • Save ficapy/7e80b24cc6c2896eb6b64cc61304dddf to your computer and use it in GitHub Desktop.
Save ficapy/7e80b24cc6c2896eb6b64cc61304dddf to your computer and use it in GitHub Desktop.
change all codesandbox public to private
const id = "YOUR ID";
const query = `
query TeamSidebarData($id: UUID4!) {
me {
team(id: $id) {
sandboxes(limit: 200, orderBy: {field: "updatedAt", direction: DESC}) {
...sandboxFragmentDashboard
}
}
}
}
fragment sandboxFragmentDashboard on Sandbox {
id
privacy
}`;
response = await fetch('https://codesandbox.io/api/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query,
variables: { id }
})
});
const resp = await response.json();
for (const sandbox of resp.data.me.team.sandboxes) {
if (sandbox.privacy === 0) {
console.log(`${sandbox.id}`)
await fetch(`https://codesandbox.io/api/v1/sandboxes/${sandbox.id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ sandbox: { privacy: 2 } })
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment