Skip to content

Resolvers not working for field schema definition #4

@pstachula-dev

Description

@pstachula-dev

TS Error

Type '() => { id: string; email: string; name: string; password: string; posts: null; }' is not assignable to type '{ id: string; email: string; name: string | null; password: string; posts: { id: string; title: string; authorId: string; content: string | null; user: ... | null; }[] | null; }'.ts(2322)

Example code:
I took looks like callbacks are wrong argument for field schema

import { Elysia } from "elysia";
import { yoga } from "@elysiajs/graphql-yoga";

const typeDefs = /* GraphQL */ `
  type User {
    id: ID!
    email: String!
    name: String
    password: String!
    posts: [Post!]
  }

  type Post {
    id: ID!
    title: String!
    authorId: String!
    content: String
    user: User
  }
`;

export const graphqlYogaPlugin = new Elysia().use(
  yoga({
    typeDefs,
    resolvers: {
      Post: {
        user: () => {
          return {
            id: "1",
            email: "test",
            name: "test",
            password: "test",
            posts: null,
          };
        },
      },
    },
  })
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions