GET /api/v1/users
POST /graphql/v1
query {
users {
id
fullName
}
}
{
users: [
{
id: 1234
fullName: "Glenn Nilsson"
}
]
}
GET /users/1
{ id, firstName, lastName, login, email, address, ... }
E.g. WBS-Rapport BasicUserInfo
query {
users {
id
firstName
lastName
email
}
}
query {
users {
fullName
login
}
}
query {
projects {
id
name
sponsor {
fullName
email
}
projectManager {
name
}
}
}
1. api/v1/projects
-> where ProjectNumber == {ProjectNumber}
2. projectId, taskSetId
-> api/v1/projects/{projectId}/tasksets/{taskSetId}/tasks
3. api/v1/propertydefinitions
-> where Name == {TaskReferenceKey}
4. For each taskId:
/api/v1/tasks/{taksId}/propertyvalues/{propertyDefinitionId}
-> where task.StringValue == {TaskReferenceValue}
Cost import via our REST API
Task matching
Task matching with GraphQL
{
tasks(where: {
task_property_values: {
_and: [
{task_property_definition:
{name: {_eq: "IntegrationStandard_TASKREF"}}},
{string_value: {_eq: "01"}}
]}})
{
id
name
task_set {
project {
project_number
name
}
}
task_property_values {
string_value
task_property_definition {
name
}
}
}
}
type User {
id: Int!
firstName: String!
}
type Project {
id: Int!
name: String!
projectManager: User!
sponsor: User
}
type Query {
getUsers: [User]
getProjects: [Project]
getUserById(id: Int!): User
}
type Mutation {
deleteUser(id: Int!): User
}
All queries under type Query
All mutations under type Mutation
Update project currencyId by projectID
REST: PATCH
RPC
GET + PUT
GET /api/v1/projects/{id}
{
"name": "ProjectName",
"projectNumber": "12345",
"deleted": false,
"useResourceRequest": true,
"currencyID": 1,
"lastPublishedTaskSetID": null,
"editTaskSetID": 2,
"latestOfficialTaskSetID": 2,
"projectTypeID": 1,
"phaseIndex": 0,
"sponsorId": 55,
"managerId": 66,
"usePlanning": true,
"canEditAfterFinish": true,
"isTemplateProject": true,
"id": 123
}
REST: Update project currencyId by projectID
PUT /api/v1/projects/{id}
{
"name": "ProjectName",
"projectNumber": "12345",
"deleted": false,
"useResourceRequest": true,
"currencyID": 2,
"lastPublishedTaskSetID": null,
"editTaskSetID": 2,
"latestOfficialTaskSetID": 2,
"projectTypeID": 1,
"phaseIndex": 0,
"sponsorId": 55,
"managerId": 66,
"usePlanning": true,
"canEditAfterFinish": true,
"isTemplateProject": true,
"id": 123
}
POST /v1/graphql
mutation {
update_projects(
where: {id: {_eq: 123}},
_set: {currency_id: 2}
)
{
affected_rows
}
}
GraphQL: Update project currencyId by projectID
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
Validation at build time
Automatic type generations (e.g. TS)
Live documentation (like Swagger)
Tooling, intellisense
Demo: Hasura, GraphiQL, Insomnia
Client
Introspection query
Schema in json
Typescript definitions
One endpoint
Response shape is flexible and defined by the request
Smaller payload
Strongly typed vs JSON in REST
Tooling/discoverability
Developer experience
React Views
Redux Store
Single Source of Truth
getState()
dispatch()
subscribe()
Thunks
API
Redux
React Views
Redux Store
Single Source of Truth
getState()
dispatch()
subscribe()
Thunks
API
Connect HoC
Redux
React Views
Server
queries()
mutations()
subscriptions()
Render Props
GraphQL
React Views
Server/DB
Single Source of Truth
queries()
mutations()
subscriptions()
Render Props
GraphQL API
Similar Application Structure to Redux
Much simpler in practice
Potential benefits for AP
Adoption strategies