@devticon-os/graphql-codegen-axios 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,29 @@ query GetFirstUser {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
|
+
### Field Selection
|
|
67
|
+
If your query selects only one field, it will be returned directly instead of being wrapped in an object. For example, the following query:
|
|
68
|
+
|
|
69
|
+
```graphql
|
|
70
|
+
query getCats {
|
|
71
|
+
cats {
|
|
72
|
+
id
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
Will generate code that directly returns the name field:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
export const getSdk = (client: AxiosInstance) => ({
|
|
80
|
+
getCats: (variables: GetCatsQueryVariables, config?: AxiosRequestConfig) =>
|
|
81
|
+
client
|
|
82
|
+
.post<GraphqlResponse<GetCatsQuery>>('', { variables, query: getCatsRawQuery }, config)
|
|
83
|
+
.then(handleResponse) // returns data from axios response
|
|
84
|
+
.then(unpackSingleResults('cats')) // returns "cats" from GetCatsQuery object,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
|
|
66
89
|
### Generating Code
|
|
67
90
|
You can generate the Axios SDK by running the following command:
|
|
68
91
|
|