Hi, I'm trying to learn a language GraphQL. I have a piece of code.
import { makeExecutableSchema } from 'graphql-tools';
const typeDefs = `
type User {
name: String!
age: Int!
}
type Query {
me: User
}
`;
const user = { name: 'Williams', age: 26};
const resolvers = {
Query: {
me: (root, args, context) => {
return user;
},
},
};
export const schema = makeExecutableSchema({
typeDefs,
resolvers,
});
export function context(headers, secrets) {
return {
headers,
secrets,
};
};
Inquiry:
{
me
}
Answer:
{
"errors": [
{
"message": "Field \"me\" of type \"User\" must have a selection of subfields. Did you mean \"me { ... }\"?",
"locations": [
{
"line": 4,
"column": 3
}
]
}
]
}
Does anyone know what I'm doing wrong? How to fix it?
source
share