0.1.2 • Published 3 months ago

mobx-graphlink v0.1.2

Weekly downloads
7
License
MIT
Repository
github
Last release
3 months ago

MobX Graphlink

Integrate data from a GraphQL backend into MobX and React with declarative path requests. (built on Apollo)

Installation

1) npm install mobx-graphlink --save-exact

The --save-exact flag is recommended (to disable version-extending), since this package uses Explicit Versioning (Release.Breaking.FeatureOrFix) rather than SemVer (Breaking.Feature.Fix).

For FeatureOrFix version-extending (recommended for libraries), prepend "~" in package.json. (for Breaking, prepend "^")

Setup

1) TODO 2) Create classes and json-schemas for row/document types. Example:

@DBClass({table: "todoItems"})
export class TodoItem {
	@DB((t, n)=>t.text(n))
	@Field({type: "string"})
	id: string;

	@DB((t, n)=>t.text(n))
	@Field({type: "string"}, {req: true})
	text: string;

	@DB((t, n)=>t.boolean(n))
	@Field({type: "string"})
	completed: boolean;

	@DB((t, n)=>t.specificType(n, "text[]"))
	@Field({items: {type: "string"}})
	tags: string[];
}

3) Create class containing DB structure information. Example:

export class GraphDBShape {
	todoItems: Collection<TodoItem>;
}

4) Create Graphlink instance:

declare module "mobx-graphlink/Dist/UserTypes" {
	// if you're using an app-wide mobx data-store, that you want easily accessible within "accessor" funcs
	interface UT_StoreShape extends RootState {}
	
	// shares the GraphDBShape class above (along with its TS type-constraints) with the mobx-graphlink library
	interface UT_DBShape extends GraphDBShape {}
}

export const graph = new Graphlink<RootState, GraphDBShape>();
store.graphlink = graph;
SetDefaultGraphOptions({graph});

export function InitGraphlink() {
	graph.Initialize({rootStore: store});
}

Usage

TODO

Alternatives

TODO

0.1.0

3 months ago

0.1.2

3 months ago

0.1.1

3 months ago

0.0.49

7 months ago

0.0.48

11 months ago

0.0.47

1 year ago

0.0.46

1 year ago

0.0.45

1 year ago

0.0.44

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.30

3 years ago

0.0.31

3 years ago

0.0.32

3 years ago

0.0.33

3 years ago

0.0.34

3 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.27

3 years ago

0.0.28

3 years ago

0.0.29

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.26

3 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago