More about GQL standard: Links
<aside> ❕ Use RunKit as interactive terminal!
</aside>
import { minilinks } from '@deep-foundation/deeplinks/imports/minilinks';
import { DeepClient } from '@deep-foundation/deeplinks/imports/deepclient';
import { generateApolloClient, IApolloClient } from "@deep-foundation/hasura/client";
const apolloClient = generateApolloClient({
path: 'pathToGqlWithoutProtocol',
ssl: true,
token: 'optionalFieldJWTToken',
});
const deep = new DeepClient({ apolloClient });
// client methods select,insert,update,delete gets options as second argument
// options always contains: { table, returning, variables, name }
await deep.select(id); // { data: [Link] }
await deep.select([id]); // { data: [Link] }
await deep.select({ id: { _in: id } }); // { data: [Link] }
await deep.insert({}); // { data: [{ id }] }
await deep.insert({
id, // can be reserved with client.reserve(count)
from_id, to_id, type_id
});
// insert with nested links and values
await deep.insert({
type_id: 1,
string: { data: { value: 'Abc' } } // <https://github.com/deep-foundation/deeplinks/issues/30>
from: { data: { type_id: 1 } },
to: { data: { type_id: 1 } },
});
await deep.update({ link: { type: { _in: [1,2,3] } } }, { value: 'abc' }, { table: 'strings' }); // { data: [{ id }] }
await deep.update(id, { value: 'abc' }, { table: 'strings' }); // { data: [{ id }] }
await deep.update([id], { value: 'abc' }, { table: 'strings' }); // { data: [{ id }] }
await deep.delete({ type: { _in: [1,2,3] } }); // { data: [{ id }] }
await deep.delete(id); // { data: [{ id }] }
await deep.delete([id]); // { data: [{ id }] }
await deep.reserve(5); // reserve count: 5 ids // [167,168,169,170,171]
await deep.await(linkId); // await all link promises resolved and rejected
// get id by packageName/userId and contain names (as Promise)
await deep.id('@deep-foundation/core', 'Promise') // 9
// Promise link in core package have global id 9 in storage
// client types cache and minilinks deepclient integration coming coon...
// in react can be used hook
import { useDeep } from '@deep-foundation/deeplinks/imports/client';
const deep = useDeep();
Authorization api documentation.
// shot syntax, you can ignore comparison level
{ id: 5 } // { id: { _eq: 5 } }
// with auto detect value relation type
{ value: 5 } // { number: { value: { _eq: 5 } } }
{ value: 'a' } // { string: { value: { _eq: 'a' } } }
{ number: 5 } // { number: { value: { _eq: 5 } } }
{ string: 'a' } // { string: { value: { _eq: 'a' } } }
// but for objects you still need full syntax
{ object: { value: { _contains: { a: 'b' } } } }
// you can walks by relations and use short syntax
{ from: { value: 5 } } // { from: { number: { value: { _eq: 5 } } } }
// selector by relations as type/from/to/typed/in/out
{ type_id: { _id: ['@deep-foundation/core', 'Value'] } }
/*
{
type: {
in: {
from: {
string: { value: { _eq: "@deep-foundation/core" } },
type_id: { _eq: 2 },
},
string: { value: { _eq: "Value" } },
type_id: { _eq: 3 },
},
},
}
*/
// 25 is AllowInsert with type=Operation 23
// 23 is Operation with type=Type 1
// is type_id typeof/instanceof from 25 (have topby tree 25 in types chain)?
{ type_id: { _type_of: 25 } }
// { type: { _by_item: { path_item_id: { _eq: 25 }, group_id: { _eq: 0 } } } }
{ from_id: { _type_of: 25 } }
// { from: { _by_item: { path_item_id: { _eq: 25 }, group_id: { _eq: 0 } } } }
{ to_id: { _type_of: 25 } }
// { to: { _by_item: { path_item_id: { _eq: 25 }, group_id: { _eq: 0 } } } }
import { useDeepQuery } from '@deep-foundation/deeplinks/imports/deepclient';
// in react component
const {
data, // array of links
error,
loading, // boolean
} = useDeepQuery(
useMemo(() => ({ type_id: 1 }), []),
useMemo(() => ({ limit: 5 }) ,[]),
);
// second argument - options, optional
// useDeepSubscription coming soon