{"id":13881028,"url":"https://github.com/jpmonette/salesforce-graphql","last_synced_at":"2025-04-19T16:12:17.375Z","repository":{"id":57356070,"uuid":"129286289","full_name":"jpmonette/salesforce-graphql","owner":"jpmonette","description":"Bringing the GraphQL query language to Salesforce ☁️","archived":false,"fork":false,"pushed_at":"2018-04-23T15:32:02.000Z","size":435,"stargazers_count":49,"open_issues_count":7,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T17:23:28.185Z","etag":null,"topics":["graphql","react","salesforce","soql","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpmonette.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-12T17:13:11.000Z","updated_at":"2023-12-28T00:09:38.000Z","dependencies_parsed_at":"2022-09-26T16:32:05.311Z","dependency_job_id":null,"html_url":"https://github.com/jpmonette/salesforce-graphql","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmonette%2Fsalesforce-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmonette%2Fsalesforce-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmonette%2Fsalesforce-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmonette%2Fsalesforce-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpmonette","download_url":"https://codeload.github.com/jpmonette/salesforce-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249734578,"owners_count":21317847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","react","salesforce","soql","typescript"],"created_at":"2024-08-06T08:03:48.743Z","updated_at":"2025-04-19T16:12:17.327Z","avatar_url":"https://github.com/jpmonette.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./assets/title.png\" alt=\"salesforce graphql\" width=\"326\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://travis-ci.org/jpmonette/salesforce-graphql\"\u003e\u003cimg src=\"https://travis-ci.org/jpmonette/salesforce-graphql.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e \u003ca href='https://coveralls.io/github/jpmonette/salesforce-graphql?branch=master'\u003e\u003cimg src='https://coveralls.io/repos/github/jpmonette/salesforce-graphql/badge.svg?branch=master' alt='Coverage Status' /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003ccode\u003esalesforce-graphql\u003c/code\u003e - Bringing the \u003cstrong\u003eGraphQL\u003c/strong\u003e query language to \u003cstrong\u003eSalesforce\u003c/strong\u003e\u003c/p\u003e\n\n## Getting Started\n\n### Installation\n\n```sh\n$ yarn add salesforce-graphql jsforce\n```\n\n### Example\n\n#### `app.ts`\n\n```ts\nimport * as jsforce from 'jsforce';\nimport * as path from 'path';\nimport * as fs from 'fs';\n\nimport { GraphQLServer } from 'graphql-yoga';\nimport { Binding } from 'salesforce-graphql';\n\nconst schemaFile = path.join(__dirname, 'schema.graphql');\nconst typeDefs = fs.readFileSync(schemaFile, 'utf8');\n\nconst { USERNAME, PASSWORD } = process.env;\n\nconst resolvers = {\n  Query: {\n    Accounts: (parent, args, context, info) =\u003e\n      context.db.query({}, info).then(res =\u003e res.records),\n    Account: (parent, args, context, info) =\u003e\n      context.db.query({}, info).then(res =\u003e res.records[0]),\n    Contacts: (parent, args, context, info) =\u003e\n      context.db.query({}, info).then(res =\u003e res.records),\n    Contact: (parentobj, args, context, info) =\u003e\n      context.db.query({}, info).then(res =\u003e res.records[0]),\n  },\n  Account: {\n    Contacts: (parent, args, context, info) =\u003e\n      context.db.query({ AccountId: parent.Id }, info).then(res =\u003e res.records),\n  },\n  Contact: {\n    Account: (parent, args, context, info) =\u003e\n      context.db.query({ Id: parent.AccountId }, info).then(res =\u003e res.records[0]),\n  },\n};\n\nconst conn = new jsforce.Connection({});\n\nfunction init() {\n  const db = new Binding({ conn });\n\n  const server = new GraphQLServer({\n    typeDefs,\n    resolvers,\n    context: req =\u003e ({ ...req, db }),\n  });\n\n  server.start({ playground: '/playground' }, ({ port }) =\u003e\n    console.log('Server is running on localhost:' + port)\n  );\n}\n\nconn.login(USERNAME, PASSWORD, (err, userinfo) =\u003e init());\n```\n\n#### `schema.graphql`\n\n```graphql\ntype Query {\n  Account(Id: ID!): Account\n  Accounts(limit: Int): [Account]\n  Contact(Id: ID!): Contact\n  Contacts(limit: Int): [Contact]\n}\n\ntype Account {\n  Id: ID!\n  IsDeleted: Boolean\n  Name: String\n  Type: String\n\n  Contacts(limit: Int): [Contact]\n}\n\ntype Contact {\n  Id: ID!\n  Account: Account\n  AccountId: String\n  LastName: String\n  FirstName: String\n  Salutation: String\n  Name: String\n}\n```\n\nWhen you are ready, start the GraphQL server:\n\n```sh\n$ yarn start\n```\n\nHead over to `http://localhost:4000/playground` to test with the following query:\n\n```graphql\n{\n  Account(Id: \"001E000001KnMkTIAV\") {\n    Id\n    Name\n    Contacts(limit: 1) {\n      Name\n      AccountId\n      Account {\n        Name\n      }\n    }\n  }\n}\n```\n\n![Sample Output](assets/output.png)\n\n## TODO\n\n* Subscriptions\n* Mutations\n* Basically everything\n\n## References\n\n- [`salesforce-graphql` on NPM](https://www.npmjs.com/package/salesforce-graphql)\n- Learn more about [GraphQL](http://graphql.org/)\n- [Salesforce REST API](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_what_is_rest_api.htm) documentation\n\n## Extra\n\n- Looking for [new opportunities](https://mavens.com/careers/)? Have a look at [Mavens](https://mavens.com/) website!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpmonette%2Fsalesforce-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpmonette%2Fsalesforce-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpmonette%2Fsalesforce-graphql/lists"}