Skip to content

Commit

Permalink
Updated readme with autoRegisterFragment example
Browse files Browse the repository at this point in the history
  • Loading branch information
deckdom committed Mar 13, 2021
1 parent dd85db0 commit 73b93e3
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,33 @@ import { FragmentStore } from 'dynql';

const store = new FragmentStore();

store.registerFragment("simple",
`fragment simple on Something {
// Manually register your fragment
store.registerFragment("simple", `fragment simple on Something {
field1
field2
...some_other
field3 {
...yet_another
}
}`);

store.resolve(`
// Automatically registers all fragments
store.autoRegisterFragment(`
fragment some_other on CoolElement {
value1
value2
nested {
...yet_another
}
}
fragment yet_another on AdvancedValue {
hell_world
}
`);

// Resolve the required fragments for the query
const resolvedFragments = store.resolve(`
query {
someResolver {
anElement {
Expand All @@ -43,11 +63,19 @@ query {
}
}`);

// Returns
[ "fragment simple on Something {
// resolvedFragments
[`fragment simple on Something {
field1
field2
}" ]
}`, `fragment some_other on CoolElement {
value1
value2
nested {
...yet_another
}
}`, `fragment yet_another on AdvancedValue {
hell_world
}`]
```

### Nested Example
Expand Down

0 comments on commit 73b93e3

Please sign in to comment.