This resource aims to facilitate the usage of GraphQL on your FiveM server. It should work with Lua/C#/JS environments.
You need webpack and yarn resources to get this script working and MongoDB.
- Download the latest release
- Extract the resource in your resources/ folder
- Go to the resource folder and start editing
db.ts
to enter your database information.
You need to create models, schemas, queries, mutations etc.. You can find a simple example in src/config/vehicles.ts
.
https://graphql.org/learn/queries/
This wrapper is relatively simple, here at the main functions.
function registerGraphSchema(name: string, config: GraphQLSchemaConfig);
It registers a "graph schema" and this schema can be later retrieved with its name.
/!\ You cannot use this function outside of the JS environment.
query(schema: string, params: string | Source, callback?: Function);
This is what you can use to execute queries/mutations with GraphQL. Example
const s = `mutation {
addVehicle(name: "Blista", plate: "ABCDEFGH", model: "blista") {
name,
model
}
}`
query('Vehicle', s, (result) => console.log(result))