$ 61.93
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Community Apps Dependencies | Show |
Lines of code | 2036 |
Technical Name |
easy_graphql |
License | OPL-1 |
Website | https://ekika.co |
Versions | 17.0 15.0 16.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Community Apps Dependencies | Show |
Lines of code | 2036 |
Technical Name |
easy_graphql |
License | OPL-1 |
Website | https://ekika.co |
Versions | 17.0 15.0 16.0 |
Odoo GraphQL API
Introduction
GraphQL is a query language for APIs and a runtime for executing those queries with existing data.
Declarative Data Fetching: GraphQL allows clients to request only the data they need and nothing more. Clients can specify the shape and structure of the response, reducing the over-fetching and under-fetching of data that often occurs in REST APIs.
Hierarchical Structure: GraphQL queries have a hierarchical structure, mirroring the shape of the response data. Clients can request nested fields, and the server responds with a JSON object that matches the requested structure.
- GraphQL Specification: https://graphql.org/learn/
How It Works
In GraphQL, queries and mutations are two types of operations used to interact with the API:
- Query Operation: A query in GraphQL is used to read or fetch data from the server. Clients can specify exactly what data they need, and the server will return only the requested data, no more and no less. Queries are similar to GET requests in REST APIs.
query MyQuery($offset: Int, $limit: Int, $order: String, $domain: [[Any]]) {
ResPartner(
offset: $offset
limit: $limit
order: $order
domain: $domain
)
{
id
name
phone
email
is_company
country_id{
name
code
}
user_id{
name
active
}
company_id{
name
}
}
}
GRAPHQL Variables for above query
{
"offset": 0,
"limit": 5,
"order": "name,id desc",
"domain": [["is_company","=",true]]
}
query MyQuery {
ResPartner(id: "33")
{
id
name
phone
email
is_company
country_id{
name
code
}
user_id{
name
active
}
company_id{
name
}
}
}
- Mutation Operation: A mutation in GraphQL is used to modify data on the server. Mutations are similar to POST, PUT, PATCH, or DELETE requests in REST APIs. Mutations can be used for creating, updating, or deleting records.
- Create Operation:
mutation Create {
createResPartner: ResPartner(
ResPartnerValues: {
active: true,
name: "Ekika Corporation New",
category_id: [4, 3]
company_type: "company",
bank_ids: [
[0, 0, {
sequence: 10,
bank_id: 2,
acc_number: "11212121212",
allow_out_payment: true,
acc_holder_name: false
}],
[0, 0, {
sequence: 11,
bank_id: 3,
acc_number: "3434343434343434",
allow_out_payment: true,
acc_holder_name: false
}]
]
city: "Gandhinagar",
street: "Gandhinagar",
street2: "",
zip: "382421",
comment: "<p>Comment Here</p>",
phone: "5554444555444",
mobile: "1010101",
website: "http://www.ekika.co",
email: "hello@ekika.co",
}
)
{
active
category_id{
id
}
bank_ids{
id
display_name
}
city
comment
company_type
id
name
phone
mobile
email
street
zip
}
}
- Update Operation:
mutation Update {
updateResPartner: ResPartner(
id: 71,
ResPartnerValues: {
active: true,
name: "Ekika Corporation PVT LTD.",
category_id: null
company_type: "company",
bank_ids: [
[1, 16, {
sequence: 25,
bank_id: 2,
allow_out_payment: true,
acc_holder_name: false
}],
[3, 17, 0]
]
}
)
{
active
category_id{
id
}
bank_ids{
id
display_name
}
city
comment
company_type
id
name
phone
mobile
email
street
zip
}
}
- Delete Operation:
mutation Delete {
deleteResPartner: ResPartner(
id: 71,
){
id
}
}
- Method Execution:
mutation Method {
methodSaleOrder: SaleOrder(
id: 16,
method_name: "action_draft",
method_parameters: {}
){
id
}
}
Configuring GraphQL Setting:
References
GraphQL Specification: https://graphql.org/learn/
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module