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
When attempting to extend a GraphQLObjectType using fields from drizzleEntities.types.UsersItem.getFields() in drizzle-graphql, the following error occurs:
Unhandled exception in handler 'server'.
✖ ExtendedUsersItem.id args must be an object with argument names as keys.
Error: ExtendedUsersItem.id args must be an object with argument names as keys.
at devAssert (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/jsutils/devAssert.js:12:11)
at path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/definition.js:793:32
at mapValue (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/jsutils/mapValue.js:16:19)
at defineFieldMap (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/definition.js:772:33)
at GraphQLObjectType._fields (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/definition.js:691:26)
at GraphQLObjectType.getFields (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/definition.js:710:27)
at collectReferencedTypes (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/schema.js:387:51)
at new GraphQLSchema (path-to-project/node_modules/.pnpm/[email protected]/node_modules/graphql/type/schema.js:179:7)
at <anonymous> (path-to-project/src/schema.ts:28:16)
✖ ExtendedUsersItem.id args must be an object with argument names as keys.
This issue appears when trying to spread the fields from drizzleEntities.types.UsersItem.getFields() into a new GraphQLObjectType to extend it.
Steps to Reproduce:
Set up a basic GraphQL schema using drizzle-graphql.
Attempt to extend an existing type using drizzleEntities.types.UsersItem.getFields() as follows:
import{GraphQLObjectType,GraphQLInt,GraphQLString}from"graphql";import{drizzleEntities}from"@/db";constExtendedUsersItem=newGraphQLObjectType({name: "ExtendedUsersItem",fields: {
...drizzleEntities.types.UsersItem.getFields(),// Include all default fields// Add custom fieldstotalPoints: {type: GraphQLInt,resolve: (user)=>user.totalPoints||0,},},});export{ExtendedUsersItem};
Start the GraphQL server and observe the error.
Expected Behavior:
The ExtendedUsersItem type should be successfully created by extending the fields from UsersItem and adding custom fields like totalPoints without causing any errors.
Actual Behavior:
The server throws an error indicating that the id field (or other fields) "must be an object with argument names as keys." This suggests that getFields() may not be handling or returning the fields in a way that is compatible with the expected GraphQLFieldConfigMap.
Environment:
drizzle-graphql version: ^0.8.4
drizzle-orm version: ^0.33.0
GraphQL version: ^16.9.0
Node.js version: v20.16.0
Operating System: Win 11
Additional Context:
The error seems related to how the fields are being spread into the ExtendedUsersItem type.
When manually specifying the fields, the issue does not occur, which suggests there may be an issue with how getFields() interacts with drizzle-graphql.
Temporary Workaround:
Manually adding the fields from UsersItem instead of using getFields() works without errors, but this is not ideal for maintaining the schema as it requires manual updates when fields change.
Request:
Please investigate whether there is a compatibility issue with getFields() when using drizzle-graphql, or if there are specific steps that should be taken to avoid this error.
The text was updated successfully, but these errors were encountered:
jacksonkasi1
changed the title
Issue: Error When Extending GraphQL Types with drizzleEntities
Issue: Error When Extending GraphQL Types with drizzleEntities(entities)
Aug 17, 2024
Seems like it's not the intended way to use .getFields() in the first place, but I'll investigate if there's something I can do about it from my side, sure.
Description:
When attempting to extend a
GraphQLObjectType
using fields fromdrizzleEntities.types.UsersItem.getFields()
indrizzle-graphql
, the following error occurs:This issue appears when trying to spread the fields from
drizzleEntities.types.UsersItem.getFields()
into a newGraphQLObjectType
to extend it.Steps to Reproduce:
drizzle-graphql
.drizzleEntities.types.UsersItem.getFields()
as follows:Expected Behavior:
The
ExtendedUsersItem
type should be successfully created by extending the fields fromUsersItem
and adding custom fields liketotalPoints
without causing any errors.Actual Behavior:
The server throws an error indicating that the
id
field (or other fields) "must be an object with argument names as keys." This suggests thatgetFields()
may not be handling or returning the fields in a way that is compatible with the expectedGraphQLFieldConfigMap
.Environment:
^0.8.4
^0.33.0
^16.9.0
Additional Context:
ExtendedUsersItem
type.getFields()
interacts withdrizzle-graphql
.Temporary Workaround:
Manually adding the fields from
UsersItem
instead of usinggetFields()
works without errors, but this is not ideal for maintaining the schema as it requires manual updates when fields change.Request:
Please investigate whether there is a compatibility issue with
getFields()
when usingdrizzle-graphql
, or if there are specific steps that should be taken to avoid this error.The text was updated successfully, but these errors were encountered: