Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Jul 26, 2024
1 parent 96b06a4 commit c03b77f
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/graph/src/-private/-edge-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export function isRHS(info: EdgeDefinition, type: string, key: string): boolean

export function upgradeDefinition(
graph: Graph,
identifier: StableRecordIdentifier,
identifier: { type: string },
propertyName: string,
isImplicit = false
): EdgeDefinition | null {
Expand Down
2 changes: 1 addition & 1 deletion packages/graph/src/-private/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class Graph {
return relationships[propertyName] !== undefined;
}

getDefinition(identifier: StableRecordIdentifier, propertyName: string): UpgradedMeta {
getDefinition(identifier: { type: string }, propertyName: string): UpgradedMeta {
let defs = this._metaCache[identifier.type];
let meta: UpgradedMeta | null | undefined = defs?.[propertyName];
if (!meta) {
Expand Down
5 changes: 5 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 1 addition & 10 deletions tests/ember-data__graph/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@ module.exports = function (environment) {
environment,
rootURL: '/',
locationType: 'history',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false,
},
},
EmberENV: {},

APP: {
// Here you can pass flags/options to your application instance
Expand Down
7 changes: 6 additions & 1 deletion tests/ember-data__graph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"lint": "eslint . --quiet --cache --cache-strategy=content --report-unused-disable-directives",
"check:types": "tsc --noEmit",
"test": "bun ./diagnostic.js",
"start": "pnpm build:tests --watch",
"test:production": "bun ./diagnostic.js",
"sync-hardlinks": "bun run sync-dependencies-meta-injected"
},
Expand Down Expand Up @@ -62,6 +63,9 @@
},
"@ember-data/debug": {
"injected": true
},
"@warp-drive/schema-record": {
"injected": true
}
},
"devDependencies": {
Expand All @@ -88,6 +92,7 @@
"@warp-drive/build-config": "workspace:0.0.0-alpha.34",
"@warp-drive/core-types": "workspace:0.0.0-alpha.83",
"@warp-drive/internal-config": "workspace:5.4.0-alpha.97",
"@warp-drive/schema-record": "workspace:0.0.0-alpha.83",
"@warp-drive/diagnostic": "workspace:0.0.0-alpha.83",
"ember-auto-import": "^2.7.4",
"ember-cli": "~5.9.0",
Expand Down Expand Up @@ -121,4 +126,4 @@
"dependencies": {
"pnpm-sync-dependencies-meta-injected": "0.0.14"
}
}
}
7 changes: 0 additions & 7 deletions tests/ember-data__graph/tests/integration/graph.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { Graph } from '@ember-data/graph/-private';
import { graphFor } from '@ember-data/graph/-private';
import Store from '@ember-data/store';
import { module, test as _test } from '@warp-drive/diagnostic';
import type { TestContext } from '@warp-drive/diagnostic/ember';
import { registerDerivations, SchemaService, withDefaults } from '@warp-drive/schema-record/schema';

interface LocalTestContext extends TestContext {
store: TestStore;
graph: Graph;
}

type DiagnosticTest = Parameters<typeof _test<LocalTestContext>>[1];
function test(name: string, callback: DiagnosticTest): void {
return _test<LocalTestContext>(name, callback);
}

class TestStore extends Store {
createSchemaService() {
const schema = new SchemaService();
registerDerivations(schema);
return schema;
}
}

module<LocalTestContext>('Integration | Graph | Resource > has-none', function (hooks) {
hooks.beforeEach(function () {
this.store = new TestStore();
this.graph = graphFor(this.store._instanceCache._storeWrapper);
});

test('Graph.getDefinition works as expected', function (assert) {
const { store, graph } = this;

// create a schema for a has-none relationship
const UserSchema = withDefaults({
type: 'user',
fields: [
{
name: 'bestFriend',
kind: 'resource',
type: 'user',
},
],
});
store.schema.registerResource(UserSchema);

// check that we can call getDefinition and get back something meaningful
const userDefinition = graph.getDefinition({ type: 'user' }, 'bestFriend');
debugger;
});
});
7 changes: 6 additions & 1 deletion tests/ember-data__graph/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
"@warp-drive/core-types": ["../../packages/core-types/unstable-preview-types"],
"@warp-drive/core-types/*": ["../../packages/core-types/unstable-preview-types/*"],
"@warp-drive/diagnostic": ["../../packages/diagnostic/unstable-preview-types"],
"@warp-drive/diagnostic/*": ["../../packages/diagnostic/unstable-preview-types/*"]
"@warp-drive/diagnostic/*": ["../../packages/diagnostic/unstable-preview-types/*"],
"@warp-drive/schema-record": ["../../packages/schema-record/unstable-preview-types"],
"@warp-drive/schema-record/*": ["../../packages/schema-record/unstable-preview-types/*"]
},
"types": ["ember-source/types"]
},
Expand Down Expand Up @@ -88,6 +90,9 @@
{
"path": "../../packages/core-types"
},
{
"path": "../../packages/schema-record"
},
{
"path": "../../packages/diagnostic"
}
Expand Down

0 comments on commit c03b77f

Please sign in to comment.