Skip to content

Include with Options GET Query Paramaters #76

Open
@brandonmikeska

Description

@brandonmikeska

Hey!

Trying to build a salesforce adapter and most of it is working well. I am trying to figure out how to specify the fields with the include.

I see you have a closed issue that talks about doing the following:
inlude={type.field}

When I try this I get the invalid link so I know my adapter isn't doing something correct. Any pointers would be awesome!

Here's my store

"use strict";

const fortune = require("fortune");
const salesforceAdapter = require("./adapters/sf-jsonapi-salesforce-handler/salesforceAdapter");

const resources = {
  Account: {
    Name: String,
    Type: String,
    CreatedDate: String,
    Contacts: [Array("Contact"), "Account"],
    Parent: "Account",
    CreatedBy: "User",
    LastModifiedBy: "User",
  },
  Contact: {
    Name: String,
    Title: Number,
    Account: ["Account", "Contacts"],
    CreatedBy: "User",
  },
  User: {
    FirstName: String,
    LastName: String,
  },
};

const hooks = {};

const options = {
  adapter: [
    salesforceAdapter,
    {
      sfURL: "****",
      sfUserName: "****",
      sfPassword: "****",
      apiVersion: "51.0",
    },
  ],
  hooks,
};

const store = fortune(resources, options);

var originalRequest = store.request;
store.request = function (opts) {
  return originalRequest.call(this, opts);
};

module.exports = store;

Here's the request

http://localhost:5000/api/accounts?include=CreatedBy.FirstName

Here's the response

{
  "jsonapi": {
    "version": "1.0"
  },
  "errors": [
    {
      "title": "BadRequestError",
      "detail": "The field \"FirstName\" does not define a link."
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions