[Operation] Projection

Specifications

In GraphQL, there isn't a specific "projection operator" as you might find in some database query languages. However, the concept of projection is inherent in how you request and structure your GraphQL queries.

In GraphQL, projection refers to the idea that the client can request only the data it needs. Unlike traditional REST APIs where the server decides what data to send, GraphQL allows clients to specify exactly what data they want in a single request.

Endpoint URL

https://api.wealthtechs.com/v2/graphql/

Authorization

// Authorization via JWT Token

Authorization: Bearer <YourToken>

Responses

CodeType
200Success
204No Content
400Bad Request
401Unauthorized

Example Code

var myHeaders = new Headers();

myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySW5mbyI6IntcIklkXCI6OTgxLFwiSWRlbnRpdHlJZFwiOlwiNjMyMzhhZTQtMzAyMC00NWI5LWEwODktOTE2ZTY4MDMyZTY3XCIsXCJVc2VyTmFtZVwiOlwiMF9URVNUX0NMSUVOVFwiLFwiRW1haWxcIjpcInRlc3RjbGllbnRAd2VhbHRodGVjaHMuY29tXCIsXCJGaXJzdE5hbWVcIjpcIlRlc3RcIixcIkxhc3ROYW1lXCI6XCJDbGllbnRcIixcIklzQ2xpZW50VXNlclwiOmZhbHNlfSIsIm5iZiI6MTY5NDcwMjU3OSwiZXhwIjoxOTI0OTIzNjAwLCJpc3MiOiJXZWFsdGhUZWNocyIsImF1ZCI6IkFQSVVzZXJzIn0.bNcP0ouNwtFoxrI7pYXw0WKiw0TN6w_R2-Ban5moo1A");

var graphql = JSON.stringify({
  query: "query Accounts {\r\n    accounts(\r\n        where: {\r\n            positions: { all: { processDate: { gte: \"2023-09-11T00:00:00.000-04:00\" } } }\r\n        }\r\n    ) {\r\n        nodes {\r\n            id\r\n            custodianId\r\n            customerId\r\n            number\r\n            master\r\n            name\r\n            accountStatus\r\n            accountType\r\n            primaryContact\r\n            mailingAddress\r\n            mailingCity\r\n            mailingState\r\n            mailingCountry\r\n            mailingZipCode\r\n            email\r\n            phone\r\n            businessPhone\r\n            dateOpened\r\n            currencyId\r\n            positions {\r\n                custodianId\r\n                customerId\r\n                processDate\r\n                accountId\r\n                securityId\r\n                shortPosition\r\n                quantity\r\n                marketValue\r\n                originalCost\r\n                originalCostDate\r\n                originalFace\r\n            }\r\n        }\r\n    }\r\n}",
  variables: {}
})

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: graphql,
  redirect: 'follow'
};

fetch("https://api.wealthtechs.com/v2/graphql/", requestOptions)
  .then(response => response.json())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Example Response

{
    "data": {
        "accounts": {
            "nodes": [
                {
                    "id": 12,
                    "custodianId": 0,
                    "customerId": 0,
                    "number": "X72843476R",
                    "master": "123456789",
                    "name": "Test Account Name",
                    "accountStatus": "Test Account Status",
                    "accountType": "Test Account Type",
                    "primaryContact": "Test Primary Contact",
                    "mailingAddress": "Test Mail Address",
                    "mailingCity": "Test Mail City",
                    "mailingState": "Test Mail State",
                    "mailingCountry": "Test Mail Country",
                    "mailingZipCode": "Test Mail Zip Code",
                    "email": "email@email.com",
                    "phone": "xxx-xxx-xxxx",
                    "businessPhone": "xxx-xxx-xxxx",
                    "dateOpened": "2023-01-01T00:00:00.000-05:00",
                    "currencyId": null,
                    "positions": [
                        {
                            "custodianId": 0,
                            "customerId": 0,
                            "processDate": "2023-09-11T00:00:00.000-04:00",
                            "accountId": 12,
                            "securityId": 8492,
                            "shortPosition": false,
                            "quantity": 200000.0000000000,
                            "marketValue": 198652.8000000000,
                            "originalCost": 199112.0000000000,
                            "originalCostDate": "1950-01-01T00:00:00.000-05:00",
                            "originalFace": null
                        },
                        {
                            "custodianId": 0,
                            "customerId": 0,
                            "processDate": "2023-09-11T00:00:00.000-04:00",
                            "accountId": 12,
                            "securityId": 8516,
                            "shortPosition": false,
                            "quantity": 200000.0000000000,
                            "marketValue": 193444.6000000000,
                            "originalCost": 200011.0000000000,
                            "originalCostDate": "1950-01-01T00:00:00.000-05:00",
                            "originalFace": null
                        },
                        {
                            "custodianId": 0,
                            "customerId": 0,
                            "processDate": "2023-09-11T00:00:00.000-04:00",
                            "accountId": 12,
                            "securityId": 8646,
                            "shortPosition": false,
                            "quantity": 500000.0000000000,
                            "marketValue": 495548.0000000000,
                            "originalCost": 500012.0000000000,
                            "originalCostDate": "1950-01-01T00:00:00.000-05:00",
                            "originalFace": null
                        }
                    ]
                }
            ]
        }
    }
}