Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include with Options GET Query Paramaters #76

Open
brandonmikeska opened this issue Mar 25, 2021 · 1 comment
Open

Include with Options GET Query Paramaters #76

brandonmikeska opened this issue Mar 25, 2021 · 1 comment

Comments

@brandonmikeska
Copy link

brandonmikeska commented Mar 25, 2021

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."
    }
  ]
}
@brandonmikeska
Copy link
Author

Actually I solved this with my custom adapter but I noticed the latest NPM package is not the same as in master. Is there a planned release version that will include the relationship changes that are on master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant