   resource_constructor: ({type, mapping, definition}) ->
     client = @
     constructor = (params, data={}) ->
-      if mapping && params && !data.url
-        data.url = client.generate_url(mapping, params)
+
+      if mapping
+        {url, path, template, query} = mapping
+        url ||= data.url
+        data.url = client.generate_url({url, path, template, query}, params)
+
       for key, value of data
         @[key] = value
       return @
 
     constructor.prototype._actions = {}
     constructor.prototype.resource_type = type
+    if mapping?.query
+      constructor.query = mapping.query
+
     # Hide the Patchboard client from such things as console.log
     Object.defineProperty constructor.prototype, "patchboard_client",
       value: @

  decorate: (schema, data) ->
    if name = schema.id?.split("#")[1]
      if constructor = @resource_constructors[name]
        data = new constructor(null, data)
    return @_decorate(schema, data) || data



  generate_url: (mapping, params) ->
    url = @api.service_url
    if template = mapping.template
      # this should never be needed when the API is served by a
      # Patchboard Server.  Including it for client-side only
      # uses, such as the GitHub API.
      parts = template.split("/")
      out = []
      for part in parts
