Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make build:schema script self-sufficient #3222

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/serious-crabs-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: make `build:schema` script self-sufficient
nedsalk marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"scripts": {
"build": "tsup",
"prebuild": "pnpm build:operations",
"build:schema": "get-graphql-schema http://127.0.0.1:4000/v1/graphql > src/providers/fuel-core-schema.graphql && prettier --write src/providers/fuel-core-schema.graphql",
"build:schema": "tsx ./scripts/generate-fuel-core-schema.mts",
"build:operations": "pnpm graphql-codegen",
"postbuild": "tsx ../../scripts/postbuild.ts"
},
Expand Down
15 changes: 15 additions & 0 deletions packages/account/scripts/generate-fuel-core-schema.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { execSync } from "child_process";
import { join } from "path";

import { setupTestProviderAndWallets } from "../src/test-utils/setup-test-provider-and-wallets";

using launched = await setupTestProviderAndWallets();

const accountPackageDir = join(process.cwd(), "packages/account");
const schemaPath = join(
accountPackageDir,
"src/providers/fuel-core-schema.graphql",
);
execSync(
`cd ${accountPackageDir} && pnpm get-graphql-schema ${launched.provider.url} > ${schemaPath} && prettier --write ${schemaPath}`,
Dismissed Show dismissed Hide dismissed
);
17 changes: 0 additions & 17 deletions packages/account/test/fuel-core-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import type { BinaryToTextEncoding } from 'crypto';
import { createHash } from 'crypto';
import { readFile } from 'fs/promises';

import { setupTestProviderAndWallets } from '../src/test-utils';

const FUEL_CORE_SCHEMA_FILE_PATH = 'packages/account/src/providers/fuel-core-schema.graphql';
const FUEL_CORE_SCHEMA_SYNC_COMMAND = 'pnpm --filter @fuel-ts/account build:schema';

Expand All @@ -23,21 +21,6 @@ function generateChecksum(
* @group node
*/
describe('fuel-core-schema.graphql', () => {
let destroy: () => void;

beforeEach(async () => {
const { cleanup } = await setupTestProviderAndWallets({
nodeOptions: {
port: '4000',
},
});
destroy = cleanup;
});

afterEach(() => {
destroy();
});

it('should not change on schema build', async () => {
const preSyncChecksum = await readFile(FUEL_CORE_SCHEMA_FILE_PATH).then(generateChecksum);

Expand Down
Loading