-
-
Notifications
You must be signed in to change notification settings - Fork 119
[Artemis 6.0.0] Two classes were generated with the same name DocumentDataType
! -- which is an enum...
#99
Comments
Yes, from 6.0+ (beta) Enums should always be the same! I'll try to use your example to fix this issue! |
Thank you. To make it a bit more easy for you, here is my complete schema. schema.graphqltype BaseSchoolEntity {
id: String!
name: String!
city: String!
theme: SchoolTheme!
authRequired: Boolean!
}
type DocumentDataEntity {
type: DocumentDataType!
data: String!
}
# Document data type
enum DocumentDataType {
PDF
IMAGE
}
type DocumentEntity implements ModuleData {
_type: String!
title: String!
description: String!
date: String!
type: DocumentDataType!
id: String!
feedback: DocumentFeedbackEntity!
}
type DocumentFeedbackEntity {
required: Boolean!
sent: Boolean!
fields: [String!]!
}
type EntryTimeEntity {
lesson: String!
length: Int!
}
type ExamEntryEntity implements ModuleData {
_type: String!
id: String!
date: String!
sClass: String!
time: EntryTimeEntity!
subject: String!
teacher: String!
comment: String!
}
interface ModuleData {
_type: String!
}
type ModuleDataEntity implements ModuleData {
_type: String!
}
type Mutation {
sickReport(body: sickReport!): SickReportEntity!
}
type PdfDataEntity {
pdf: String!
}
type Query {
school: SchoolEntity
schools: [BaseSchoolEntity!]
moduleDataSubst(moduleId: String!): [SubstitutionPlanEntity!]
moduleDataExams(moduleId: String!): [ExamEntryEntity!]
moduleDataDocuments(moduleId: String!): [DocumentEntity!]
moduleDataDocumentsData(id: String!, moduleId: String!): DocumentDataEntity!
pdfData(moduleId: String!): PdfDataEntity!
}
type SchoolEntity {
id: String!
name: String!
city: String!
theme: SchoolTheme!
authRequired: Boolean!
website: String!
image: String!
hidden: Boolean!
codeOfConduct: [String!]!
features: [SchoolFeatureEntity!]!
modules: [SchoolModuleEntity!]!
substData: [[SubstitutionPlanEntity!]!]!
}
type SchoolFeatureEntity {
type: SchoolInformationFeatureType!
}
# School information feature type
enum SchoolInformationFeatureType {
SICK_REPORT
}
# School module category
enum SchoolModuleCategory {
SUBST
EXAMS
CAFETERIA
NEWS
DOCUMENTS
OTHER
}
type SchoolModuleEntity {
dataType: SchoolModuleType!
id: String!
category: SchoolModuleCategory!
suffix: String!
}
# School module type
enum SchoolModuleType {
SUBST
EXAMS
NEWS
CAFETERIA
PDF
DOCUMENTS
}
# School theme
enum SchoolTheme {
RED
PINK
PURPLE
DEEP_PURPLE
INDIGO
BLUE
LIGHT_BLUE
CYAN
TEAL
GREEN
LIGHT_GREEN
AMBER
ORANGE
DEEP_ORANGE
BROWN
GREY
BLUE_GREY
}
input sickReport {
name: String!
sClass: String!
message: String!
attested: Boolean!
duration: sickReportDuration!
specialEvent: String!
}
input sickReportDuration {
start: String!
end: String!
}
type SickReportDurationEntity {
start: String!
end: String!
}
type SickReportEntity {
name: String!
sClass: String!
message: String!
attested: Boolean!
duration: SickReportDurationEntity!
specialEvent: String!
}
# Subst entry type
enum SubstEntryType {
EVA
SUBST
CANCELLED
EXAM
NORMAL
SHIFTED_TO
INSTEAD_OF
SPECIAL
BREAK_SUPERVISORY
CUSTOM
}
type SubstitutionEntryAdditionalDataEntity {
taskBy: [String!]!
postponed: [SubstitutionEntryAdditionalDataTimeEntity!]!
insteadOf: [SubstitutionEntryAdditionalDataTimeEntity!]!
customType: String!
}
type SubstitutionEntryAdditionalDataTimeEntity {
date: String!
time: EntryTimeEntity!
}
type SubstitutionEntryEntity {
date: String!
sClass: String!
room: String!
comment: String!
subject: String!
newSubject: String!
missingTeacher: String!
teacher: String!
time: EntryTimeEntity!
type: SubstEntryType!
additionalData: SubstitutionEntryAdditionalDataEntity!
}
type SubstitutionPlanEntity implements ModuleData {
_type: String!
date: String!
entries: [SubstitutionEntryEntity!]!
messages: [String!]!
}
|
This helps a lot, thanks! |
Hi @lazylazyllama - I can suggest you a temp fix, As far as I have a lot of work at the beginning of the project
I'll try to find a time for a better solution on the next week. |
Another way to circumvent this issue is temporarily have only one query on each file, but each of the generated files would still have the same enum. |
Take a note that the @comigor’s solution could lead the entities import mess. Nevertheless it’s also valid) Who knows what surprises are hidden behind my solution... |
That should not in any terms be considered a solution, but just a way to temporarily make things work 😂 I'd like to discuss better how to gracefully generate the canonical classes (enums, input objects and fragments) in a non-duplicated and shareable way. I'll start a RFC taking in account the ideas proposed by @vasilich6107 later. |
Thank you a lot for your ideas how to fix it temporarily. I really appreciate that. But it's all fine. I'm not in a rush or something. I have a lot of other things to do. So I'm totally fine if it will be fixed in the upcoming weeks. :) |
Hi, just to say that I am encountering the same issue. Thank you very much :) |
Same here! Thank you for your work, it makes using GraphQL such a pleasure! 🚀 |
Created new branch from latest beta release with dedup fix - |
@comigor I propose the next approach - generate all canonical(enums, fragments, inputs) types which referred from the queries to the separate file. So on the step of generating the query types we will generate only with query dependent names and refer to the canonical ones through the import of canonical file. |
Yes, that's the way I'm thinking of doing: having a top-level configuration of schema and canonical pathes, somewhat like this: targets:
$default:
builders:
artemis:
options:
schema_mapping: # schema_mapping now becomes the global configuration
- schema: lib/my_graphql_schema.graphql # each mapping will refer to a single schema
canonical_output: lib/canonical_types.dart # with a canonical file output (enums, fragments, inputs)
fragments_glob: lib/fragments/**.fragment.graphql
scalar_mapping: # scalar mapping also refer to the schema, so they're configured here
- custom_parser_import: package:my_package/coercers.dart
graphql_type: BigDecimal
dart_type:
name: Decimal
imports:
- package:decimal/decimal.dart
queries_mapping: # and we now have a queries_mapping for this same schema as well
- query: lib/**.graphql # (actually a glob)
output: lib/api.dart |
I'm trying last beta and I have this error when I have multiple queries or mutations in one file. If create one file for each query or mutation it's working fine. Does it matter? It's not supported? |
@onemanstartup It can be that both queries refer to the same GraphQL type and them both would generate Dart classes with the same name, which's considered an error, because each one of them could have different set of fields. |
@comigor
I am going to implement the fix for duplication only for |
Can we have additional Example: if developer do not want to bother with juggling the output between folders he can specify a single |
I would also like to discuss a drop of As far as we saw previously What do you think? |
@vasilich6107 I'm all-in with all of those! Only about the |
Makes sense. |
@lazylazyllama |
It seems to be working :) |
Error:
Queries:
DocumentDataType gql schema:
build.yaml:
I use Artemis 6.0
Why do I get this error? Shouldn't Enums always be the same? Meaning that you can just use the same enum class on both queries?
Changing
naming_scheme
topathedWithFields
makes no difference.The text was updated successfully, but these errors were encountered: