Skip to content

Instantly share code, notes, and snippets.

View tchak's full-sized avatar
GH drop ICE

Paul Chavard tchak

GH drop ICE
View GitHub Profile
@tchak
tchak / query.gql
Created July 30, 2020 09:40
Query avec PieceJustificativeChamp
query getDossier($dossierNumber: Int!) {
dossier(number: $dossierNumber) {
id
number
champs {
id
label
stringValue
... on PieceJustificativeChamp {
file {
import { RecordIdentity } from '@orbit/data';
import { SyncLiveQuery } from '@orbit/record-cache';
import { consume, dirty } from './tracked';
import { ReadonlyArray } from './readonly-array';
export class LiveQueryArray<M extends RecordIdentity> extends ReadonlyArray<M> {
private readonly _liveQuery: SyncLiveQuery;
private get _content(): M[] {
return this._liveQuery.query() as M[];
import { Source, SourceSettings, buildTransform } from '@orbit/data';
import {
createConsumer,
Cable,
ChannelNameWithParams
} from '@rails/actioncable';
import { JSONAPISerializer, ResourceOperationsDocument } from '@orbit/jsonapi';
export interface ActionCableSourceSettings extends SourceSettings {
cable?: Cable;
mutation($dossierId: ID!, $instructeurId: ID!, $body: String!, $attachment: ID) {
dossierEnvoyerMessage(input: {
dossierId: $dossierId,
instructeurId: $instructeurId,
body: $body,
attachment: $attachment
}) {
message {
body
}
@tchak
tchak / store.ts
Last active October 20, 2019 17:32
Orbit Store Interface
import { QueryResultData } from '@orbit/record-cache';
import { FilterQBParam, SortQBParam, PageQBParam, QueryOrExpression, TransformOrOperations } from '@orbit/data';
export interface Identifier {
type?: string;
id?: string;
lid?: string;
}
export interface LiveArray<Model> extends Iterable<Model> {
@tchak
tchak / json-schema.ts
Last active August 31, 2019 15:00
Orbit JSONSchema
import { Schema } from '@orbit/data';
import { JSONAPISerializer } from '@orbit/jsonapi';
import { Dict } from '@orbit/utils';
export interface JSONSchemaType {
type: 'object' | 'string' | 'number' | 'boolean';
pattern?: string;
}
export interface JSONSchemaRef {
@tchak
tchak / hints-with-meta-2.js
Last active July 3, 2019 17:29
Orbit hints with meta
class MyMemorySource extends MemorySource {
async _query(query, hints) {
if (hints && hints.data) {
let identities = hints.data.primaryData ? hints.data.primaryData : hints.data;
let data;
if (Array.isArray(identities)) {
data = this._cache.query(q => q.findRecords(identities));
} else {
data = this._cache.query(q => q.findRecord(identities));
}
@tchak
tchak / orbit-jsonapi-client.md
Last active June 24, 2019 17:29
Orbit jsonapi Client

Is it possible to use Orbit.js as a simple fetching client with a json:api server? The answer is yes, with certain caveats. First one is you still need to write a schema.

import { Schema } from '@orbit/data';
import JSONAPISource from '@orbit/jsonapi’;

const schema = new Schema({
  models: {
    article: {
      attributes: {
@tchak
tchak / action-cable-source.ts
Last active May 30, 2019 21:47
Orbit ActionCableSource
import Orbit, {
Source,
SourceSettings,
RecordOperation,
buildTransform
} from '@orbit/data';
import {
JSONAPISerializer,
JSONAPISerializerSettings,
ResourceOperationsDocument
@tchak
tchak / demarches-simplifiees-api.php
Created July 2, 2018 09:01
demarches-simplifiees.fr exemple api
<?php
class DemarchesSimplifiees {
function __construct($token) {
$this->token = $token;
}
function procedure($procedure_id) {
return $this->request("procedures/$procedure_id");
}