@jumpn/utils-graphql
Advanced tools
Comparing version 0.4.1 to 0.5.0
{ | ||
"name": "@jumpn/utils-graphql", | ||
"version": "0.4.1", | ||
"version": "0.5.0", | ||
"description": "GraphQL utilities", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.js", |
@@ -17,2 +17,4 @@ # @jumpn/utils-graphql | ||
- [hasSubscription](#hassubscription) | ||
- [requestFromCompat](#requestfromcompat) | ||
- [requestToCompat](#requesttocompat) | ||
- [License](#license) | ||
@@ -127,4 +129,60 @@ | ||
### requestFromCompat | ||
Creates a GqlRequest using given GqlRequestCompat | ||
**Parameters** | ||
- `gqlRequestCompat` **GqlRequestCompat<Variables>** | ||
- `gqlRequestCompat.query` | ||
- `gqlRequestCompat.variables` | ||
**Examples** | ||
```javascript | ||
const query = ` | ||
query userQuery($userId: ID!) { | ||
user(userId: $userId) { | ||
id | ||
} | ||
} | ||
`; | ||
console.log(requestFromCompat({query, variables: {userId: 10}})); | ||
// {operation: "...", variables: {userId: 10}} | ||
``` | ||
Returns **GqlRequest<Variables>** | ||
### requestToCompat | ||
Creates a GqlRequest using given GqlRequestCompat | ||
**Parameters** | ||
- `gqlRequest` **GqlRequest<Variables>** | ||
- `gqlRequest.operation` | ||
- `gqlRequest.variables` | ||
**Examples** | ||
```javascript | ||
const operation = ` | ||
query userQuery($userId: ID!) { | ||
user(userId: $userId) { | ||
id | ||
} | ||
} | ||
`; | ||
console.log(requestToCompat({operation, variables: {userId: 10}})); | ||
// {query: "...", variables: {userId: 10}} | ||
``` | ||
Returns **GqlRequestCompat<Variables>** | ||
## License | ||
[MIT](LICENSE.txt) :copyright: **Jumpn Limited** / Mauro Titimoli (mauro@jumpn.com) |
28734
187