Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolvers not working for field schema definition #4

Open
pstachula-dev opened this issue Oct 6, 2023 · 0 comments
Open

Resolvers not working for field schema definition #4

pstachula-dev opened this issue Oct 6, 2023 · 0 comments

Comments

@pstachula-dev
Copy link

pstachula-dev commented Oct 6, 2023

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,
          };
        },
      },
    },
  })
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant