Skip to content

PichotM/graphql-fivem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL Wrapper for FiveM

This resource aims to facilitate the usage of GraphQL on your FiveM server. It should work with Lua/C#/JS environments.

Installation

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.

Configuration

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/

Examples

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))

About

GraphQL wrapper for FiveM

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published