   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: @

  generate_url: (mapping, params) ->
    url = @api.service_url
    if template = mapping.template
      parts = template.split("/")
      out = []
      for part in parts

  create_directory: (mappings, constructors) ->
    for name, mapping of mappings
      do (name, mapping) =>
        {url, query} = mapping
        if !(url || query)
          throw new Error "Mapping lacks a url, path, or template field"
        if constructor = constructors[name]
          if mapping.url
            if mapping.query
              @resources[name] = (params={}) ->
                new constructor(params)
            else
              @resources[name] = new constructor(null, url: mapping.url)
        else
          throw new Error "No constructor for '#{name}'"

