Following a tutorial at the moment to do with C# Azure functions and GraphQL. Having a little trouble with the Schema for the GraphQL Types.
Here is my Model User class:
public class User : Base
{
private User()
{
}
public User(string name, string email, bool adminUser, DateTime birthday, string dietaryRequirements, Squad squad)
{
Name = name;
Email = email;
AdminUser = adminUser;
Birthday = birthday;
DietaryRequirements = dietaryRequirements;
InformationRequired = true;
Squad = squad;
}
public string Name { get; set; }
public string Email { get; set; }
public bool AdminUser { get; set; } = false;
public DateTime Birthday { get; set; }
public string DietaryRequirements { get; set; }
public bool InformationRequired { get; set; }
public Squad Squad { get; set; }
}
And the corresponding Schema in GraphQL:
public class Type
{
private ISchema _Schema { get; set; }
public Type()
{
this._Schema = Schema.For(@"
type User {
Id: GUID
Name: string
Email: string
AdminUser: bool
Birthday: Date
DietaryRequirements: List<string>
InformationRequired: boolean
Squad: squad
}
input User {
Id: GUID
Name: string
Email: string
AdminUser: bool
Birthday: Date
DietaryRequirements: List<string>
InformationRequired: boolean
Squad: squad
}
type Mutation {
createUser(input: User) : User
getUsers() : User
getUserById(id: Id) : User
updateUser(input: User) : User
deleteUser(id: Id) : string
}
type Query {
users: [User]
user(id: Id) : User
}
", _ =>
{
_.Types.Include<Query>();
_.Types.Include<Mutation>();
});
}
}
}
I am following this tutorial: https://softchris.github.io/pages/dotnet-graphql-serverless.html#adding-a-graphql-schema under the "Adding a GraphQL schema section".
The issue I am having is with the last few lines of the Type class where I have:
_.Types.Include<Query>
_.Types.Include<Mutation>();
IntelliSense is throwing up an error here as it does not find the namespace required for this. For the Query it recommends adding using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
but the original author does not use this package so I assume it is wrong. Similarly, for Mutation, it has the same error but does not recommend any packages to import.
Can anyone see what I am doing wrong here or any errors I am failing to pick up one?