Skip to content

Commit 7fabcc2

Browse files
v0.0.8
1 parent 3cabc66 commit 7fabcc2

5 files changed

Lines changed: 74 additions & 37 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
id-token: write # Required for OIDC
10+
contents: read
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
registry-url: 'https://registry.npmjs.org'
22+
23+
# Ensure npm 11.5.1 or later is installed
24+
- name: Update npm
25+
run: npm install -g npm@latest
26+
- run: npm ci
27+
- run: npm run build --if-present
28+
- run: npm test
29+
- run: npm publish

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ This section aims to describe all the environment variables exposed to configure
125125

126126
To see an example of sensible defaults, see the [env.example](./.env.example) configuration file.
127127

128-
## Installing from npm Registry
128+
## Installing from npm
129+
130+
This package is published to npm and is available for public access
131+
132+
```sh
133+
npm install mina-archive-node-graphql
134+
```
135+
136+
## Installing from artifact registry
129137

130138
This package is published to a Google Cloud Artifact Registry and is available for public access.
131139

@@ -157,11 +165,13 @@ To create a new release, follow these steps:
157165
3. **Create and push a tag**: `git tag v1.2.3 && git push origin v1.2.3`
158166

159167
The CI/CD workflow will automatically:
168+
160169
- Build and publish npm package to GCP registry with version from package.json
161170
- Build and push Docker image to both GCP Artifact Registry and GitHub Container Registry
162171
- Create semantic version tags (e.g., `1.2.3`, `1.2`, `1`, `latest`)
163172

164173
**Published artifacts:**
174+
165175
- npm: `https://europe-southwest1-npm.pkg.dev/o1labs-192920/euro-npm/`
166176
- Docker (GCP): `europe-west3-docker.pkg.dev/o1labs-192920/euro-docker-repo/archive-node-api`
167177
- Docker (GitHub): `ghcr.io/o1-labs/archive-node-api`

package-lock.json

Lines changed: 4 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
2-
"name": "archive-node-graphql",
3-
"version": "1.0.0",
2+
"name": "mina-archive-node-graphql",
3+
"version": "0.0.8",
44
"description": "A NodeJS GraphQL server for exposing data for o1js/zkApps",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/o1-labs/Archive-Node-API"
88
},
99
"main": "build/src/index.js",
1010
"start": "build/src/index.js",
11+
"files": [
12+
"build/"
13+
],
1114
"type": "module",
1215
"scripts": {
13-
"build": "npm run clean && npx tsc",
16+
"build": "npm run clean && npx tsc && cp schema.graphql build/",
1417
"start": "node build/src/index.js",
1518
"dev": "cross-env NODE_NO_WARNINGS=1 npx nodemon --exec 'node -r dotenv/config --loader ts-node/esm' src/index.ts",
1619
"test": "./run-tests.sh",

src/resolvers.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,44 @@ import {
66
TracingState,
77
setSpanNameFromGraphQLContext,
88
} from './tracing/tracer.js';
9+
import { join } from 'path';
10+
11+
const graphqlSchemaPath = join(__dirname, '..', 'schema.graphql');
912

1013
const fullResolvers: Resolvers = {
1114
Query: {
1215
events: async (_, { input }, context) => {
13-
const graphQLSpan = setSpanNameFromGraphQLContext(context, 'events.graphql');
16+
const graphQLSpan = setSpanNameFromGraphQLContext(
17+
context,
18+
'events.graphql'
19+
);
1420
return context.db_client.getEvents(input, {
1521
tracingState: new TracingState(graphQLSpan),
1622
});
1723
},
1824
actions: async (_, { input }, context) => {
19-
const graphQLSpan = setSpanNameFromGraphQLContext(context, 'actions.graphql');
25+
const graphQLSpan = setSpanNameFromGraphQLContext(
26+
context,
27+
'actions.graphql'
28+
);
2029
return context.db_client.getActions(input, {
2130
tracingState: new TracingState(graphQLSpan),
2231
});
2332
},
2433
networkState: async (_, __, context) => {
25-
const graphQLSpan = setSpanNameFromGraphQLContext(context, 'networkState.graphql');
34+
const graphQLSpan = setSpanNameFromGraphQLContext(
35+
context,
36+
'networkState.graphql'
37+
);
2638
return context.db_client.getNetworkState({
2739
tracingState: new TracingState(graphQLSpan),
2840
});
2941
},
3042
blocks: async (_, { query, limit, sortBy }, context) => {
31-
const graphQLSpan = setSpanNameFromGraphQLContext(context, 'blocks.graphql');
43+
const graphQLSpan = setSpanNameFromGraphQLContext(
44+
context,
45+
'blocks.graphql'
46+
);
3247
return context.db_client.getBlocks(query, limit, sortBy, {
3348
tracingState: new TracingState(graphQLSpan),
3449
});
@@ -41,7 +56,9 @@ let typeDefs: string | undefined = undefined;
4156

4257
// If the ENABLED_QUERIES environment variable is set, filter the schema and resolvers.
4358
if (process.env.ENABLED_QUERIES !== undefined) {
44-
const enabledQueries = process.env.ENABLED_QUERIES.split(',').map((q) => q.trim());
59+
const enabledQueries = process.env.ENABLED_QUERIES.split(',').map((q) =>
60+
q.trim()
61+
);
4562

4663
// If the list is not empty, filter the resolvers.
4764
if (enabledQueries.length > 0) {
@@ -54,7 +71,7 @@ if (process.env.ENABLED_QUERIES !== undefined) {
5471
};
5572

5673
// Filter the schema AST.
57-
const typeDefsString = fs.readFileSync('./schema.graphql', 'utf-8');
74+
const typeDefsString = fs.readFileSync(graphqlSchemaPath, 'utf-8');
5875
const typeDefsAst = parse(typeDefsString);
5976
const modifiedAst = visit(typeDefsAst, {
6077
ObjectTypeDefinition(node) {
@@ -76,7 +93,7 @@ if (process.env.ENABLED_QUERIES !== undefined) {
7693
// Create the executable schema.
7794
const schema = makeExecutableSchema({
7895
resolvers: [resolvers],
79-
typeDefs: typeDefs || fs.readFileSync('./schema.graphql', 'utf-8'),
96+
typeDefs: typeDefs || fs.readFileSync(graphqlSchemaPath, 'utf-8'),
8097
});
8198

8299
export { resolvers, schema };

0 commit comments

Comments
 (0)