Strapi: Is there a to override plugin GraphQL schema?

Viewed 471

I am trying to modify the GraphQL schema of the users-permissions plugin.

I want to change:

type UsersPermissionsLoginPayload {
    jwt: String!
    user: UsersPermissionsMe!
}

to:

type UsersPermissionsLoginPayload {
  isAuthenticated: Boolean!
  user: UsersPermissionsMe!
}

But I get many errors when I create ./extensions/users-permissions/config/schema.graphql.js:

...

There can be only one type named "UsersPermissionsLoginInput".

Field "UsersPermissionsLoginInput.identifier" can only be defined once.

Field "UsersPermissionsLoginInput.password" can only be defined once.

Field "UsersPermissionsLoginInput.provider" can only be defined once.

There can be only one type named "UsersPermissionsLoginPayload".

Field "UsersPermissionsLoginPayload.jwt" can only be defined once.

Field "UsersPermissionsLoginPayload.user" can only be defined once.

...

What is the correct way to customize/extend the schema?

Edit:

I see the types can simply be extended like so:

module.exports = {
  definition: `
    extend type UsersPermissionsLoginPayload {
      isAuthenticated: Boolean!
   }
  `
}

that adds the isAuthenticated field to the UsersPermissionsLoginPayload type but does not remove the jwt field.

Is there no way to override the typedefs and resolvers? Do I need to implement my custom functionality using new types and new unique resolvers?

0 Answers
Related