You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Allow to provide FieldConfig via function (#3)
* feat: Allow to provide FieldConfig via function
* docs: add links to live demo and it's repo
* docs: Adjust examples
* docs: fix demo repo link
* docs: reorganize `README.md`
Add schema building and custom fetching example.
Generalize examples.
* docs: small readme fixes
This is a plugin for [graphql-compose](https://github.com/nodkz/graphql-compose), which derives GraphQLType from REST response. Also derives bunch of internal GraphQL Types.
10
+
This is a plugin for [graphql-compose](https://github.com/nodkz/graphql-compose), which generates GraphQLTypes from REST response or any JSON. It takes fields from object, determines their types and construct GraphQLObjectType with same shape.
11
11
12
-
## Getting started
12
+
## Demo
13
13
14
-
### Demo
14
+
We have a [Live demo](https://graphql-compose-swapi.herokuapp.com/?query=%7B%0A%20%20person%28id%3A%201%29%20%7B%0A%20%20%20%20name%0A%20%20%20%20films%20%7B%0A%20%20%20%20%20%20title%0A%20%20%20%20%20%20release_date%0A%20%20%20%20%20%20director%0A%20%20%20%20%7D%0A%20%20%20%20homeworld%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20climate%0A%20%20%20%20%20%20diameter%0A%20%20%20%20%7D%0A%20%20%20%20starships%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20cost_in_credits%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A) (source code [repo](https://github.com/lyskos97/graphql-compose-swapi)) which shows how to build an API upon [SWAPI](https://swapi.co) using `graphql-compose-rest`.
15
15
16
-
We have a [demo app](demo/) which shows how to build an API upon [SWAPI](https://swapi.co) using `graphql-compose-rest`.
Modules `graphql`, `graphql-compose`, are located in `peerDependencies`, so they should be installed explicitly in your app. They have global objects and should not have ability to be installed as submodule.
31
23
32
-
### Examples
24
+
##Example
33
25
34
-
We have a sample response object:
26
+
You have a sample response object`restApiResponse` which you can pass to `graphql-compose-rest` along with desired type name as your first argument and it will automatically generate a composed GraphQL type `PersonTC`.
which we pass to a `composeWithRest` function of `graphql-compose-rest` along with desired type name as first argument in order to generate a `GraphQL` type:
56
+
## Customization
57
+
58
+
You can write custom field configs directly to a field of your API response object via function (see `mass` and `starships_count` field):
prepareArgs: {// you're free to define `resolve` the way you want
160
+
prepareArgs: {
85
161
urls:source=>source.films,
86
162
},
87
163
});
88
164
```
89
165
90
-
`graphql-compose` provides a vast variety of methods for types' `fields` and `resolvers` (aka `field configs` in vanilla `GraphQL`) management. To learn more visit [graphql-compose repo](https://github.com/nodkz/graphql-compose).
166
+
`graphql-compose` provides a vast variety of methods for `fields` and `resolvers` (aka field configs in vanilla `GraphQL`) management of `GraphQL` types. To learn more visit [graphql-compose repo](https://github.com/nodkz/graphql-compose).
0 commit comments