Skip to content

Invalid caching of raw query with selected_operation #221

Open
@theduke

Description

@theduke

Currently, using the same file and selected_operation in the custom derive does not work.

The generated const QUERY = ""... is the same string for all the generated modules, re-using the value of the first generated.

Eg:

mutation Login($account: String!, $user: String!, $password: String!) {
    login(account: $account, user: $user, password: $password) {
        account {
            id
            identifier
            name
        }
        user {
            id
            username
            email
        }
        token
    }
}

mutation Signup($data: SignupInput!) {
    signup(data: $data) {
        account {
            id
            identifier
            name
        }
        user {
            id
            username
            email
        }
        token
    }
}

mutation BookmarkCreate($url: String!, $title: String!, $description: String) {
    bookmarkCreate(url: $url, title: $title, description: $description) {
        ...Bookmark
    }
}

fragment Bookmark on Bookmark {
    id
    url
    title
    description
}

query Bookmarks {
    bookmarks {
        ...Bookmark
    }
}
mutation Login($account: String!, $user: String!, $password: String!) {
    login(account: $account, user: $user, password: $password) {
        account {
            id
            identifier
            name
        }
        user {
            id
            username
            email
        }
        token
    }
}

mutation Signup($data: SignupInput!) {
    signup(data: $data) {
        account {
            id
            identifier
            name
        }
        user {
            id
            username
            email
        }
        token
    }
}

mutation BookmarkCreate($url: String!, $title: String!, $description: String) {
    bookmarkCreate(url: $url, title: $title, description: $description) {
        ...Bookmark
    }
}

fragment Bookmark on Bookmark {
    id
    url
    title
    description
}

query Bookmarks {
    bookmarks {
        ...Bookmark
    }
}

Result:

mod login {
  const QUERY: &'static str = "mutation Login ....";
}
mod signup {
  // Query re-used !
  const QUERY: &'statc str = "mutation Login...";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions