Skip to main content

Extensions

Falcon-Server provides its own base GraphQL Schema, that defines data types, queries and mutations, so every Extension could use its types and extend them.

Currently, Deity provides the following list of officially supported extensions:

Each of these can of course be extended with custom features that are specific for particular implementation.

Extending GraphQL context with extension

Besides providing schema for GraphQL server, extensions can also provide function that modifies GraphQL execution context which is available in resolvers.

To do so, the extension must return context property which is an object or function that creates object. That object will be merged with default context values and context values returned from other extensions.

This is ApolloServer's feature exposed by Falcon Server and you can read more about it here

Code snipped below shows the basic usage.

// example extension that adds "key": "value" pair to the GraphQL context
module.exports = () => ({
context: ({ ctx }) => {
return {
key: 'value'
};
}
});

// then in resolver's code it will be available under context.key
...
someQueryResolver: (obj, input, context, info) {
console.log('Key value:', context.key);
}
...

Internally for example GeoLocation Extension uses that mechanism to inject geo location data to each request's context.

(todo)