This section provides a detailed reference for GraphQL queries used to manage publishing projects, releases, and associated resources. These queries allow you to retrieve information about your blocklets' publishing lifecycle. For operations that modify this data, such as creating or updating projects and releases, please refer to the Publishing & Projects Mutations documentation.
getProjects
Retrieves a list of publishing projects associated with a specific blocklet.
Example
Get a list of projects
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchProjects() {
try {
const { projects, paging } = await client.getProjects({
input: {
did: 'z8ia262k3g55v12a874bf7ae1666c268882b6',
paging: {
page: 1,
pageSize: 10,
},
},
});
console.log('Projects:', projects);
console.log('Paging Info:', paging);
} catch (error) {
console.error('Error fetching projects:', error);
}
}
fetchProjects();Parameters
- input
RequestGetProjectsInput(required) — The input object for the query.- did
string(required) — The DID of the blocklet. - paging
PagingInput— Pagination information. - componentDid
string— Filter projects by component DID. - tenantScope
string— Filter projects by tenant scope.
- did
Return Type
Returns a ResponseGetProjects object containing an array of Project objects and pagination details.
Example Response
Response for getProjects
{
"code": "ok",
"projects": [
{
"id": "z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3",
"type": "pack",
"blockletDid": "z8ia262k3g55v12a874bf7ae1666c268882b6",
"blockletTitle": "My Awesome Blocklet",
"createdAt": "2023-10-27T10:00:00.000Z",
"updatedAt": "2023-10-27T10:00:00.000Z",
"lastReleaseId": "z3t8b..._release_id_...",
"connectedStores": []
}
],
"paging": {
"page": 1,
"pageSize": 10,
"total": 1,
"pageCount": 1
}
}getProject
Retrieves details for a single publishing project using its ID.
Example
Get a single project
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchProject(projectId) {
try {
const { project } = await client.getProject({
input: {
did: 'z8ia262k3g55v12a874bf7ae1666c268882b6',
projectId: projectId,
},
});
console.log('Project Details:', project);
} catch (error) {
console.error('Error fetching project:', error);
}
}
fetchProject('z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3');Parameters
- input
RequestProjectInput(required) — The input object for the query.- did
string(required) — The DID of the blocklet. - projectId
string(required) — The unique identifier of the project to retrieve. - messageId
string— A message identifier for tracking requests.
- did
Return Type
Returns a ResponseGetProject object containing the Project details.
Example Response
Response for getProject
{
"code": "ok",
"project": {
"id": "z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3",
"type": "pack",
"blockletDid": "z8ia262k3g55v12a874bf7ae1666c268882b6",
"blockletTitle": "My Awesome Blocklet",
"blockletDescription": "A blocklet that does awesome things.",
"autoUpload": true,
"connectedStores": []
}
}getReleases
Fetches a list of releases for a given publishing project.
Example
Get releases for a project
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchReleases(projectId) {
try {
const { releases } = await client.getReleases({
input: {
did: 'z8ia262k3g55v12a874bf7ae1666c268882b6',
projectId: projectId,
},
});
console.log('Releases:', releases);
} catch (error) {
console.error('Error fetching releases:', error);
}
}
fetchReleases('z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3');Parameters
- input
RequestGetReleasesInput(required) — The input object for the query.- did
string(required) — The DID of the blocklet. - projectId
string(required) — The ID of the project whose releases are to be fetched. - paging
PagingInput— Pagination information.
- did
Return Type
Returns a ResponseGetReleases object containing an array of Release objects and pagination information.
Example Response
Response for getReleases
{
"code": "ok",
"releases": [
{
"id": "z3t8bCDE...",
"projectId": "z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3",
"blockletDid": "z8ia262k3g55v12a874bf7ae1666c268882b6",
"blockletVersion": "1.2.0",
"note": "Initial release with new features.",
"status": "published",
"createdAt": "2023-10-27T12:00:00.000Z"
}
],
"paging": {
"page": 1,
"pageSize": 10,
"total": 1,
"pageCount": 1
}
}getRelease
Retrieves details for a single release using its ID.
Example
Get a single release
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchRelease(projectId, releaseId) {
try {
const { release } = await client.getRelease({
input: {
did: 'z8ia262k3g55v12a874bf7ae1666c268882b6',
projectId: projectId,
releaseId: releaseId,
},
});
console.log('Release Details:', release);
} catch (error) {
console.error('Error fetching release:', error);
}
}
fetchRelease('z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3', 'z3t8bCDE...');Parameters
- input
RequestReleaseInput(required) — The input object for the query.- did
string(required) — The DID of the blocklet. - projectId
string(required) — The ID of the parent project. - releaseId
string(required) — The unique identifier of the release to retrieve.
- did
Return Type
Returns a ResponseGetRelease object containing the Release details.
Example Response
Response for getRelease
{
"code": "ok",
"release": {
"id": "z3t8bCDE...",
"projectId": "z2qa7xsgE59VUp2r1LqfE9F2fJ6dZ8cR9yB3",
"blockletVersion": "1.2.0",
"blockletTitle": "My Awesome Blocklet",
"note": "Initial release with new features.",
"status": "published"
}
}getSelectedResources
Fetches a list of resource identifiers that have been selected for a specific component within a release.
Example
Get selected resources for a release
import BlockletServerClient from '@blocklet/server-js';
const client = new BlockletServerClient();
async function fetchSelectedResources(projectId, releaseId, componentDid) {
try {
const { resources } = await client.getSelectedResources({
input: {
did: 'z8ia262k3g55v12a874bf7ae1666c268882b6',
projectId: projectId,
releaseId: releaseId,
componentDid: componentDid,
},
});
console.log('Selected Resources:', resources);
} catch (error) {
console.error('Error fetching selected resources:', error);
}
}
fetchSelectedResources('z2qa7...', 'z3t8b...', 'z2qa...');Parameters
- input
RequestGetSelectedResourcesInput(required) — The input object for the query.- did
string(required) — The DID of the blocklet. - projectId
string(required) — The ID of the project. - releaseId
string(required) — The ID of the release. - componentDid
string(required) — The DID of the component whose selected resources are to be fetched.
- did
Return Type
Returns a ResponseGetSelectedResources object containing an array of resource strings.
Example Response
Response for getSelectedResources
{
"code": "ok",
"resources": [
"resource:zde22a874bf7ae1666c268882b6...",
"resource:zde22a874bf7ae1666c268882b7..."
]
}To create, update, or delete these entities, please proceed to the Publishing & Projects Mutations section.