@devticon-os/graphql-codegen-axios 0.2.6 → 0.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devticon-os/graphql-codegen-axios",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "repository": "https://github.com/devticon/graphql-codegen-axios",
package/src/helpers.ts CHANGED
@@ -25,15 +25,13 @@ const firstOrFail = (key: string, reqParams: GraphqlRequestParams) => (data: any
25
25
  return data;
26
26
  };
27
27
 
28
- const nonNullable =
29
- <T>(reqParams: GraphqlRequestParams) =>
30
- (data: T) => {
31
- const row = data;
32
- if (!row) {
33
- throw new QueryNoResultsError(reqParams);
34
- }
35
- return row;
36
- };
28
+ const nonNullable = (key: string, reqParams: GraphqlRequestParams) => (data: any) => {
29
+ const row = data[key];
30
+ if (!row) {
31
+ throw new QueryNoResultsError(reqParams);
32
+ }
33
+ return data;
34
+ };
37
35
 
38
36
  export const handleResponse = <T>({ data }: AxiosResponse<GraphqlResponse<T>>) => {
39
37
  const errors = data.errors;
package/src/render.js CHANGED
@@ -47,7 +47,7 @@ const renderTypeField = (fields, config) => {
47
47
  if (isNullable) {
48
48
  tsType = `Nullable<${tsType}>`;
49
49
  }
50
- return `${name}: ${tsType}`;
50
+ return `${name}${isNullable ? '?' : ''}: ${tsType}`;
51
51
  })
52
52
  .join(',\n');
53
53
  };