Skip to content

Instantly share code, notes, and snippets.

🏢
working

Paul Chavard tchak

🏢
working
Block or report user

Report or block tchak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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: {
@tchak
tchak / action-cable-source.ts
Last active May 30, 2019
Orbit ActionCableSource
View action-cable-source.ts
import Orbit, {
Source,
SourceSettings,
RecordOperation,
buildTransform
} from '@orbit/data';
import {
JSONAPISerializer,
JSONAPISerializerSettings,
ResourceOperationsDocument
@tchak
tchak / demarches-simplifiees-api.php
Created Jul 2, 2018
demarches-simplifiees.fr exemple api
View demarches-simplifiees-api.php
<?php
class DemarchesSimplifiees {
function __construct($token) {
$this->token = $token;
}
function procedure($procedure_id) {
return $this->request("procedures/$procedure_id");
}
@tchak
tchak / nginx-mobile-redirect
Last active Dec 1, 2016 — forked from dangayle/nginx-mobile-redirect
NGINX Mobile redirect
View nginx-mobile-redirect
# Set $mobile_rewrite variable
set $mobile_rewrite do_not_perform;
# Check if user agent is a mobile
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|fennec|ip(hone|od)|kindle|mobile.+firefox|opera m(ob|in)i|iemobile") {
set $mobile_rewrite perform;
}
# Check if query arg = yes (example.com?mobile=yes), set variable
if ($arg_mobile = 'yes') {
View account.js
export Model.extend({
followers: hasMany('user', { async: true }),
following: hasMany('user', { async: true })
});
// If you don't want to return account from API, just create a local model.
// This can be used on 1.13 even if you not using JSON-API adapter/serializer.
// `store.push()` is always taking JSON-API payload.
// When pushing current adapter/serializer format you are using `store.pushPayload()`.
store.push({
You can’t perform that action at this time.