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
I am trying to put my generated Amplify API together with RTK Query for the convenience of codegen'ed hooks.
I am creating the baseQueryFn, which requires the generateClient() to accept a query - DocumentNode.
When I import the DocumentNode type from graphql to satisfy my TS linter, I get a type error. (See log output)
It appears that there is a difference in the way graphql 15.8.0 and 16.8.1 define the DocumentNode... with v17 around the corner, it seems like a good time to create an upgraded version.
Expected behavior
I would expect to see the two DocumentNode objects match.
Reproduction steps
Install @reduxjs/toolkit, @aws-amplify/api, and @rtk-query/graphql-request-base-query. Make sure you have a typescript linter running
Paste the snippet
Notice the warning on line 16 where the query field is assigned.
Code Snippet
import{BaseQueryFn,createApi}from"@reduxjs/toolkit/query/react";import{generateClient}from"@aws-amplify/api";import{ErrorResponse}from"@rtk-query/graphql-request-base-query/dist/GraphqlBaseQueryTypes";import{DocumentNode}from"graphql";exportconstgraphqlRequestBaseQuery=<E=ErrorResponse>(): BaseQueryFn<{document: string|DocumentNode;variables?: unknown},unknown,E> =>{constclient=generateClient();returnasync({ document, variables })=>{try{const{ data, errors }=awaitclient.graphql({query: document,
variables,});}catch(error){throw`API Error: ${error}`;}};};
// initialize an empty api service that we'll inject endpoints into later as needed
export const api = createApi({reducerPath: "graphql",baseQuery: graphqlRequestBaseQuery(),endpoints: ()=>({}),});
Log output
Type 'string | import("/Users/crich/development/github/Agroview2.0/node_modules/graphql/language/ast").DocumentNode' is not assignable to type 'string | import("/Users/crich/development/github/Agroview2.0/node_modules/@aws-amplify/api-graphql/node_modules/graphql/language/ast").DocumentNode'.
Type 'DocumentNode' is not assignable to type 'string | DocumentNode'.
Type 'import("/Users/crich/development/github/Agroview2.0/node_modules/graphql/language/ast").DocumentNode' is not assignable to type 'import("/Users/crich/development/github/Agroview2.0/node_modules/@aws-amplify/api-graphql/node_modules/graphql/language/ast").DocumentNode'.
Types of property 'loc' are incompatible.
Type 'import("/Users/crich/development/github/Agroview2.0/node_modules/graphql/language/ast").Location | undefined' is not assignable to type 'import("/Users/crich/development/github/Agroview2.0/node_modules/@aws-amplify/api-graphql/node_modules/graphql/language/ast").Location | undefined'.
Type 'import("/Users/crich/development/github/Agroview2.0/node_modules/graphql/language/ast").Location' is not assignable to type 'import("/Users/crich/development/github/Agroview2.0/node_modules/@aws-amplify/api-graphql/node_modules/graphql/language/ast").Location'.
The types returned by 'startToken.toJSON()' are incompatible between these types.
Type '{ kind: TokenKind; value?: string | undefined; line: number; column: number; }' is not assignable to type '{ kind: TokenKindEnum; value: string | undefined; line: number; column: number; }'.
Property 'value' is optional in type '{ kind: TokenKind; value?: string | undefined; line: number; column: number; }' but required in type '{ kind: TokenKindEnum; value: string | undefined; line: number; column: number; }'.
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered:
I do see there are some type errors when following the reproduction steps. I'll bring this to the team for consideration on upgrading the graphql version
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
None
Environment information
Describe the bug
I am trying to put my generated Amplify API together with RTK Query for the convenience of codegen'ed hooks.
I am creating the
baseQueryFn
, which requires thegenerateClient()
to accept a query - DocumentNode.When I import the
DocumentNode
type fromgraphql
to satisfy my TS linter, I get a type error. (See log output)It appears that there is a difference in the way graphql 15.8.0 and 16.8.1 define the DocumentNode... with v17 around the corner, it seems like a good time to create an upgraded version.
Expected behavior
I would expect to see the two DocumentNode objects match.
Reproduction steps
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: