import gql from "graphql-tag" ; import { Model } from "../../Model" ; import { ReplicatorQueries } from "./ReplicatorQueries" ; /**
 * Builds GraphQL queries for models following
 * the [GraphQLCRUD specification] https export const buildGraphQLCRUDQueries = ( model ) => { const fields = model . getFields ( ) ; const fieldsBuilder = Object . keys ( fields ) . map ( ( key ) => { const graphQLKey = fields [ key ] . key ; return graphQLKey ; } ) ; const graphQLFields = fieldsBuilder . join ( "\n" ) ; const modelName = model . getName ( ) ; const queries = { sync : gql `
            query sync${ modelName }($lastSync: GraphbackTimestamp!, $filter: ${ modelName }Filter) {
              sync${ modelName }s(lastSync: $lastSync, filter: $filter) {
                  items {
                    ${ graphQLFields }
                    _deleted
                  }
                  lastSync
              }
            }` } ; return queries as ReplicatorQueries ; } ;