An open API service indexing awesome lists of open source software.

https://github.com/idkjs/swapi-dataloader


https://github.com/idkjs/swapi-dataloader

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# dataloader-codegen Example: Star Wars API (SWAPI)

Shows an example of a GraphQL Server using dataloader-codegen. Prints data from https://swapi.dev.

## Try it out locally!

Clone dataloader-codegen and build locally:

```sh
$ git clone [email protected]:Yelp/dataloader-codegen.git
$ cd dataloader-codegen
$ make build
$ yarn link
```

Build the example:

```sh
$ cd examples/swapi
$ yarn
$ yarn link dataloader-codegen
$ make swapi-loaders.js
$ make build
# Prints out a GraphQL query result:
$ node build/swapi-server.js
```

## File Layout:

- `swapi-loaders.js`: An autogenerated file by dataloader-codegen. Contains the codegen'd dataloaders. (Checked in to git so folks can easily see an example of the generated code).
- `swapi.js`: A set of functions to fetch data from https://swapi.dev/. This is analogous to a library generated by openapi-generator/swagger-codegen.
- `swapi-server.js`: The dummy GraphQL server! This imports the dataloaders from swapi-loaders.js. At present, it just prints the result of a query to stdout.