Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing headers for authorization changes Content Type #341

Open
crimson-med opened this issue Oct 3, 2022 · 0 comments
Open

Changing headers for authorization changes Content Type #341

crimson-med opened this issue Oct 3, 2022 · 0 comments

Comments

@crimson-med
Copy link

When I use Chain to send a request with a header. TheContent-Type is changes by GraphQL Zeus to a "utf-8"

This is with no header:

import { Chain, GraphQLTypes, InputType } from "../../zeus";

export const CreateSession = async (data: GraphQLTypes['SessionCreateInput'], token: string) => {
    try {
        const createSessionData = await Chain((process.env.REACT_APP_GRAPHQL as string), {
            // headers: {
            //     Authorization: token,
            // },
        })('mutation')({
            createSession: [
                { data },
                { id: true }
            ]
        });
        if (createSessionData.createSession) {
            return true
        }
        return undefined
    } catch (error) {
        return undefined
    }
};

Screenshot 2022-10-04 at 3 29 50 AM

Now if I uncomment and add the header the Content-Type changes:

import { Chain, GraphQLTypes, InputType } from "../../zeus";

export const CreateSession = async (data: GraphQLTypes['SessionCreateInput'], token: string) => {
    try {
        const createSessionData = await Chain((process.env.REACT_APP_GRAPHQL as string), {
            headers: {
                Authorization: token,
            },
        })('mutation')({
            createSession: [
                { data },
                { id: true }
            ]
        });
        if (createSessionData.createSession) {
            return true
        }
        return undefined
    } catch (error) {
        return undefined
    }
};

Screenshot 2022-10-04 at 3 33 01 AM

I have also tried adding the Content=Type as a proper header but this keeps it as text/plain

import { Chain, GraphQLTypes, InputType } from "../../zeus";

export const CreateSession = async (data: GraphQLTypes['SessionCreateInput'], token: string) => {
    try {
        const createSessionData = await Chain((process.env.REACT_APP_GRAPHQL as string), {
            headers: {
                Authorization: token,
                "Content-Type": "application/json"
            },
        })('mutation')({
            createSession: [
                { data },
                { id: true }
            ]
        });
        if (createSessionData.createSession) {
            return true
        }
        return undefined
    } catch (error) {
        return undefined
    }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant