Skip to content

--graphql type name collision #73

@thomasdfischer

Description

@thomasdfischer

Infer this JSON (to pretty-print it, pipe it into jq or schema translate or python -m json.tool) with --graphql:

{"templates":[{"name":"data","filePath":"data.csv","schema":{"filePath":""}},{"name":"config","filePath":"config.toml","schema":{"filePath":""}}],"instances":[{"filePath":"data-2000.csv","templateName":["data"],"schema":{"filePath":""}},{"filePath":"data-2001.csv","templateName":["data"],"schema":{"filePath":""}},{"filePath":"data-2002.csv","templateName":["data"],"schema":{"filePath":""}},{"filePath":"config_dev.toml","templateName":["config","data"],"schema":{"filePath":""}},{"filePath":"mysingletoner","templateName":["config"],"schema":{"filePath":""}}],"singletons":[{"filePath":".gitignore"}],"noGit":false}

schema infer --graphql yields this output:

type Schema {
    filePath: String!
}

type Templates {
    name: String!
    filePath: String!
    schema: Schema!
}

type Schema {
    filePath: String!
}

type Instances {
    templateName: [String!]!
    schema: Schema!
    filePath: String!
}

type Singletons {
    filePath: String!
}

type Object {
    templates: [Templates!]!
    instances: [Instances!]!
    singletons: [Singletons!]!
    noGit: Boolean!
}

which has two definitions of the Schema type.

To fix this bug, we need to

  1. If type collision happens AND the two types have the same exact fields, only output the type once
  2. If type collision happens AND the two types are different, rename one of the types
  3. Allow both of the above solutions to scale to any number of colliding types

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingurgent

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions