Osclass API ( GraphQL ) Released - Use it for building the next Osclass Mobile App. Community support on github is welcome

We have developed a GraphQL API for Osclass, It´s built using Laravel, Simply connect your existing database details from osclass to this laravel project

then run php artisan serve

Then access your API using myapidomain.com/graphql

I will add more detailed documentation soon, Please star it and watch it on github

type Query {

    categories: [Category] @all
    category(pk_i_id: ID @eq): Category @find
    categoryDescriptionByLocale(fk_c_locale_code: String! @eq): [CategoryDescription] @all #todo

    avatars: [Avatar] @all
    avatar(fk_i_user_id: ID @eq): Avatar @find

    #userDescriptions: [UserDescription] @all #todo
    # userDescriptions(fk_c_locale_code: ID! @eq): [UserDescription] @all #todo

    me: User @middleware(checks:["auth:api"]) @auth

    countries: [Country] @all
    country(pk_c_code: ID @eq): Country @find
    region(pk_i_id: ID @eq): Region @find
    city(pk_i_id: ID @eq): City @find

    items: [Item] @all
    item(pk_i_id: ID @eq): Item @find

    itemDescriptions: [ItemDescription] @all
    itemDescription(fk_i_item_id: ID @eq): [ItemDescription] @all

    itemLocations: [ItemLocation] @all
    itemLocation(fk_i_item_id: ID @eq): ItemLocation @find

    itemMetas: [ItemMeta] @all
    itemMeta(fk_i_item_id: ID @eq): [ItemMeta] @all

    itemResources: [ItemResource] @all
    itemResource(pk_i_id: ID @eq): ItemResource @find
    allItemResources(fk_i_item_id: ID @eq): [ItemResource] @all
    firstItemResource(fk_i_item_id: ID @eq): ItemResource @first

    itemStats: [ItemStat] @all
    itemStat(fk_i_item_id: ID @eq): [ItemStat] @all

    itemCommentsByItem(fk_i_item_id: ID @eq): [ItemComment] @all

    locales: [Locale] @all
    locale(pk_c_code: ID @eq): Locale @find

    currencies: [Currency] @all
    currency(pk_c_code: ID @eq): Currency @find

    preferences: [Preference] @all
    preference(s_section: ID @eq): [Preference] @all

    metaFields: [MetaField] @all
    metaField(pk_i_id: ID @eq): MetaField @find

    metaCategories: [MetaCategory] @all
    metaCategory(fk_i_category_id: ID @eq): [MetaCategory] @all
    metaCategoryByField(fk_i_field_id: ID @eq): [MetaCategory] @all


    appSettings: [AppSetting] @all
    appSetting(id: ID @eq): AppSetting @find

}

type UserDescription {
    fk_i_user_id: ID!
    fk_c_locale_code: ID!
    s_info: String
    user: User! @belongsTo
    locale: Locale! @belongsTo
}

type Category {
    pk_i_id: ID!
    fk_i_parent_id: Int
    i_expiration_days: Int
    i_position: Int
    b_enabled: Boolean
    b_price_enabled: Boolean
    s_icon: String
    categoryStat: CategoryStat @hasOne
    categoryDescriptions: [CategoryDescription] @hasMany
}

type CategoryStat {
    fk_i_category_id: ID!
    i_num_items: Int
    category: Category! @belongsTo
}

type CategoryDescription {
    fk_i_category_id: ID!
    fk_c_locale_code: String
    s_name: String
    s_description: String
    s_slug: String
    category: Category! @belongsTo

}

type Locale {
    id: ID!                               @rename(attribute: "pk_c_code")
    name: String                          @rename(attribute: "s_name")
    description: String                   @rename(attribute: "s_description")
    shortName: String                     @rename(attribute: "s_short_name")
    currencyFormat: String                @rename(attribute: "s_currency_format")
    decimalPoint: String                  @rename(attribute: "s_dec_point")
    thousandsSeparator: String            @rename(attribute: "s_thousands_sep")
    numberOfDecimals: Int                 @rename(attribute: "i_num_dec")
    dateFormat: String                    @rename(attribute: "s_date_format")
    stopWords: String                     @rename(attribute: "s_stop_words")
    enabledForUsers: Boolean              @rename(attribute: "b_enabled")
    enabledForAdmins: Boolean             @rename(attribute: "b_enabled_bo")
    userDescriptions: [UserDescription]   @hasMany
}

type Country {
    pk_c_code: ID!
    s_name: String
    s_slug: String
    countryStat: CountryStat @hasOne
    regions: [Region!]! @hasMany
}

type Region {
    pk_i_id: ID!
    fk_c_country_code: String!
    s_name: String
    s_slug: String
    b_active: Boolean
    regionStat: RegionStat @hasOne
    cities: [City!]! @hasMany
    country: Country! @belongsTo

}

type City {
    pk_i_id: ID!
    fk_i_region_id: String!
    s_name: String
    s_slug: String
    fk_c_country_code: String!
    b_active: Boolean
    cityStat: CityStat @hasOne
    region: Region! @belongsTo
}

type CountryStat {
    fk_c_country_code: ID!
    i_num_items: Int
    country: Country @belongsTo
}

type RegionStat {
    fk_i_region_id: ID!
    i_num_items: Int
    region: Region @belongsTo
}

type CityStat {
    fk_i_city_id: ID!
    i_num_items: Int
    city: City @belongsTo
}

type Item {
    pk_i_id: ID!
    fk_i_user_id: Int
    fk_i_category_id: Int
    dt_pub_date: String #Temporary
    dt_mod_date: String #Temporary
    i_price: Float
    fk_c_currency_code: String
    s_contact_name: String
    s_contact_email: String
    b_premium: Boolean
    b_enabled: Boolean
    b_active: Boolean
    b_spam: Boolean
    #s_secret: // Only see if admin
    #s_ip: // Only see if admin
    #b_show_email: // Not needed
    dt_expiration: String #Temporary
}

type ItemComment {
    fk_i_item_id: ID! #review
    pk_i_id: Int
    dt_pub_date: String #Temporary
    s_title: String
    s_author_name: String
    s_author_email: String
    s_body: String
    b_enabled: Boolean
    b_active: Boolean
    b_spam: Boolean
    fk_i_user_id: Int
}

type ItemDescription {
    fk_i_item_id: ID!
    fk_c_locale_code: String
    s_title: String
    s_description: String
}

type ItemLocation {
    fk_i_item_id: ID!
    fk_c_country_code: String
    s_country: String
    s_address: String
    s_zip: String
    fk_i_region_id: Int
    s_region: String
    fk_i_city_id: Int
    s_city: String
    fk_i_city_area_id: Int
    s_city_area: String
    d_coord_lat: String #Temporary
    d_coord_lon: String #Temporary
}

type ItemMeta {
    fk_i_item_id: ID!
    fk_i_field_id: Int
    s_value: String
    s_multi: String
}

type ItemResource {
    pk_i_id: ID!
    fk_i_item_id: Int
    s_name: String
    s_extension: String
    s_content_type: String
    s_path: String
}

type ItemStat {
    fk_i_item_id: ID!
    i_num_views: Int
    i_num_spam: Int
    i_num_repeated: Int
    i_num_bad_classified: Int
    i_num_offensive: Int
    i_num_expired: Int
    i_num_premium_views: Int
    dt_date: String #Temporary
}

type Currency {
    pk_c_code: ID!
    s_name: String
    s_description: String
    b_enabled: Boolean
}

type Preference {
  s_section: ID!
  s_name: String
  s_value: String
  e_type: String  # CHANGE TO ENUM
}

type MetaField {
  pk_i_id: ID!
  s_name: String
  s_slug: String
  e_type: String  # CHANGE TO ENUM
  s_options: String
  b_required: Boolean
  b_searchable: Boolean
}

type MetaCategory {
  fk_i_category_id: ID!
  fk_i_field_id: ID
}

type AppSetting {
  id: ID!
  email: String
  website: String
  appVersion: String         @rename(attribute: "app_version")
  aboutUs: String            @rename(attribute: "about_us")
  headerImages: String       @rename(attribute: "header_images")
  privacyPolicy: String      @rename(attribute: "privacy_policy")
  userTerms: String          @rename(attribute: "user_terms")
  facebookUrl: String        @rename(attribute: "facebook_url")
  twitterUrl: String         @rename(attribute: "twitter_url")
  youtubeUrl: String         @rename(attribute: "youtube_url")
  instagramUrl: String       @rename(attribute: "instagram_url")
}


type Mutation {
    createItem(input: CreateItemInput! @spread): Item! @create
}

input CreateItemInput {
    fk_i_category_id: Int
    i_price: Float
    fk_c_currency_code: String
    s_contact_name: String
    s_contact_email: String
    b_premium: Boolean
    b_enabled: Boolean
    b_active: Boolean
}

Check this file to get an idea of the current GraphQl queries and mutations supported.

2 Likes