Skip to content

Instantly share code, notes, and snippets.

Avatar
GH drop ICE

Paul Chavard tchak

GH drop ICE
View GitHub Profile
@tchak
tchak / query.gql
Created Jul 30, 2020
Query avec PieceJustificativeChamp
View query.gql
query getDossier($dossierNumber: Int!) {
dossier(number: $dossierNumber) {
id
number
champs {
id
label
stringValue
... on PieceJustificativeChamp {
file {
View TrackedLiveQuery.ts
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[];
View read-only-array.ts
export interface IReadonlyArray<T> extends Iterable<T> {
/**
*
*/
readonly length: number;
/**
* Combines two or more arrays.
* @param items Additional items to add to the end of array1.
*/
View action-cable-source.ts
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;
View envoyer-message.gql
mutation($dossierId: ID!, $instructeurId: ID!, $body: String!, $attachment: ID) {
dossierEnvoyerMessage(input: {
dossierId: $dossierId,
instructeurId: $instructeurId,
body: $body,
attachment: $attachment
}) {
message {
body
}
@tchak
tchak / introspection.gql
Last active Nov 20, 2019
GraphQL IntrospectionQuery
View introspection.gql
query IntrospectionQuery {
__schema {
queryType {
name
}
mutationType {
name
}
types {
...FullType
@tchak
tchak / store.ts
Last active Oct 20, 2019
Orbit Store Interface
View store.ts
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 Aug 31, 2019
Orbit JSONSchema
View json-schema.ts
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 Jul 3, 2019
Orbit hints with meta
View hints-with-meta-2.js
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 Jun 24, 2019
Orbit jsonapi Client
View orbit-jsonapi-client.md

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: {
You can’t perform that action at this time.